MERGE Tk.2 | How To: Multiple Records / One Page

Tried asking this a month ago - some looked but no one knew or was able to help out - trying again, maybe I’ll be luckier this time :slight_smile:

Hi! I’m trying to merge a LO Calc spreadsheet source file with a LO Writer document. These are not address labels.

PROBLEM – right now I can only get one record on each page. The merge is automatically creating a new page for every record.

The spreadsheet source data is actually coming out of iTunes (playlist data) … so the data is song titles, album names, song duration, comments, etc.

I am trying to create a Writer document where one page contains multiple records, and only when the page is full of records, is a second page started.

Unfortunately, all I can find is information about printing labels, or creating personalized form letters where it makes sense to have one record per page/document.

In some records some fields may be blank; in some records field length may be longer or shorter.

Typically with Word & Excel (which I’m trying to get away from) about 25 records can easily be merged onto 3 pages.

Appreciate any feedback, instructions, links to posts already answering exactly how to do this. My research with things like inserting “Next Record” (Database Fields) hasn’t proved successful.

Thanks! (See Example records below)

Below is an example of 3 records and how the merge comes out using Word/Excel – and what I’m trying to reproduce in LO on a single page, multiple records one below the other:

10 | How Dare You | 06:43 | [ end at: 1:05:52 ] St Germain | St Germain | Warner Bros Records |
95 Boulevard / 99 From Detroit to St Germain / 2000 Tourist / 2015 St Germain album Tourist (2.8 million copies Ludovic Navarre

11 | Raven | 04:58 | [ end at: 1:10:50 ] GoGo Penguin | A Humdrum Star | Blue Note | 2018
Manchester-based trio / Neal Blacka B | Chris Illingworth P | Rob Turner D | Rel Feb 9 2016

12 | The Touch Of Your Lips | 05:50 | [ end at: 1:16:40 ] Joey Defrancesco | (Ray Noble) Trip Mode | High Note |
JD P* TP* Vx** | Mike Boone B | Jason Brown D |

This has been a real pain over the years. It has always been possible, but the rules have changed multiple times
As of LO 62,3,2 the following seems to be true. I’ll describe a table with a fixed number of lines but a variable number of entries, but the ideas do not require a table.

  • Mail merge handles only one record at a time, i.e. has no idea of what has passed and what is to come
  • if your data source is a spreadsheet, you can include fields with forward and backward references
  • every instance you want to fill on every line in the table must be filled with entries in the text template
  • it follows that these fields all have to be conditional, except possiby the first line

Here is a very limited example.
The table has two columns, NAME and HOBBY and a number of lines
We need a local variable to keep track, let’s call it Valid. If the first line in a group is alway shown, set Valid = 1
at the beginning of your docunment
Insert “Conditional text” fields on all lines of your table: if Valid == 1 then mydb.Query.NAME (same for HOBBY)
Now your spreadsheet must hint at if the next record belongs on this page or not, lets call it CONT
After the last entry on every line of the table add two more fields
Valid = mydb.Query.CONT and “Next record” if mydb.Query.CONT
Now each record that is preceded by CONT = 1 will be added on consecutive lines iin the table
When CONT is 0 lines will be empty, “Next record” is not triggered and Merge shifts to the following “letter”

This approach allows for more complex forward and backward references. The basic idea remains that the spreadsheet logic must provide that information.