Page 1 of 1
[Solved] Mail merge: Conditionally omit records
Posted: Wed Dec 28, 2022 9:13 pm
by rowan.bradley
I am trying to print some address labels from data in a spreadsheet. I have a column in the spreadsheet called Print which is set to "Yes" if that row is to be printed, and to blank if it is not. There are 14 labels on one sheet, so my mail merge document prints 14 labels, and uses "Next record" to move to the next before each individual label. How do I omit the records that do not have Print set to Yes?
Thank you - Rowan
Re: Mail merge: how to conditionally omit some records
Posted: Wed Dec 28, 2022 11:05 pm
by John_Ha
Sort on the column with "Yes" and print only the first "yes" records.
Re: Mail merge: how to conditionally omit some records
Posted: Thu Dec 29, 2022 12:55 am
by rowan.bradley
Is there no "filter" facility like MS Word has? Where you can specify a boolean expression containing field values? I'm sure I have seen this in "how to" pages.
Rowan
Re: Mail merge: how to conditionally omit some records
Posted: Thu Dec 29, 2022 3:54 am
by John_Ha
Not to my knowledge. The User Guide says
In the Mail Merge dialog box (Figure 309), you can choose to print all records or selected records. To select records to be printed, use Ctrl+click to select individual records. To select a block of records, select the first record in the block, scroll to the last record in the block, and Shift+click on the last record.
Re: Mail merge: how to conditionally omit some records
Posted: Thu Dec 29, 2022 8:20 am
by Mountaineer
rowan.bradley wrote: ↑Thu Dec 29, 2022 12:55 am
Is there no "filter" facility like MS Word has? Where you can specify a boolean expression containing field values? ...
I've not tried this with a spreadsheet, as my data now resides in databases, but we can query datasources with Base. "Simple" datasources like csv and dBase does not support the full range of options a real sql-Database like sqlite, hsqldb or firebird would give but simple queries are possible.
Word has to do a lot of stuff "alone" as it was sold separate and people had neither Excel, nor Access to help. Aoo/LO have an integrated component to handle data/databases, so does not need to repeat this functions in Writer.
Re: Mail merge: how to conditionally omit some records
Posted: Fri Dec 30, 2022 1:42 am
by MrProgrammer
rowan.bradley wrote: ↑Wed Dec 28, 2022 9:13 pm
conditionally omit some records
You will specify which records to
include, not which records to
omit.
rowan.bradley wrote: ↑Wed Dec 28, 2022 9:13 pm
I have a column in the spreadsheet called Print which is set to "Yes" if that row is to be printed, and to blank if it is not.
Creating Mail Merge Documents From Text/CSV or Spreadsheets
Mail Merge requires a Writer document (the layout to be printed) and a Base document (the data source). You can connect to a spreadsheet when configuring your data source, but you
must have a Base document. After connecting Base to your spreadsheet,
create and save a query in the Base document to retrieve only the rows you want, perhaps something like:
SELECT YourFields FROM YourTable WHERE "Print" = 'Yes'
Instead of entering the
SQL for the query, as I did above, you can use a wizard to build the query for you. Then, after creating your Writer document containing mail merge fields, use Edit → Exchange Database and select the query you created as the data source for the merge. Then use File → Print → Form letter? → Yes.
rowan.bradley wrote: ↑Thu Dec 29, 2022 12:55 am
Is there no "filter" facility …?
There is, though I think it will be more convenient to use a query unless you're only going to do this once. File → Print → Form letter? → Yes will display this dialog. I'd use Standard Filter, but you can use AutoFilter too.
Read the documentation to learn more.
Using Mail Merge
Getting Started with Base

- Standard Filter.gif (55.24 KiB) Viewed 11792 times
If this solved your problem please go to your first post use the Edit ☐ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.