#1
|
|||
|
|||
Mail merge with filter using data inputted by user
Hi,
I'm quite a novice when it comes to mail merge. I have a document set up (word 2003) that gets it's data using mail merge from an Excel spreadsheet. The data required is determined by a 'date' field and a 'shift' field. At present I can manually go to mailings/edit list/filter and set the required date and shift values. This works fine, but different people are going to be using this on a daily basis, so I would like to have a text box for 'date' and 'shift' in the main word document which the user can enter, and the filter will then run on these values. Explaining to each user how to edit the values in mailings/edit list/filter will no doubt cause problems. Is this possible? Would appreciate some advice on how to set this up. |
#2
|
||||
|
||||
Hi Tornado70,
Assuming you only want the output to reflect a nominated shift on a nominated dat, you could use a SKIPIF field, coded along the lines of: {SKIPIF{={IF{MERGEFIELD MyDate \@ YYYYMMDD}={FILLIN "Date to include (in YYYYMMDD format, please)." \@ YYYYMMDD \o } 1 0}*{IF{MERGEFIELD Shift}={FILLIN "Shift to include." \o} 1 0}}= 0} Note: The field brace pairs (ie '{ }') for the above example are created in the body of the document via Ctrl-F9 (Cmd-F9 on a Mac) - you can't simply type them or copy & paste them from this message.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks for the information, I had no idea where to start but this has helped. I can't quite get the code you gave to work correctly, it prompts for the date and shift but whatever I enter it still pulls in all records.
I have worked out from your code how to use the SKIPIF command to get records for today's date and a specified 'shift', which means using a separate document for each shift will give me what I need. It would be nice to have the prompt working to give the option of printing other dates. Just in case it helps, the date field is in UK format, ie DDMMYYYY and the shift field is either: 6-2 or 2-10 If there are any other suggestions it would be much appreciated. |
#4
|
||||
|
||||
Hi Tornado70,
A 'date' in a DDMMYYYY format isn't a date - it's just an 8-digit number. To work with that, you'd need to change the field code to: {SKIPIF{={IF{MERGEFIELD MyDate}={FILLIN "Date to include (in DDMMYYYY format, please)." \o} 1 0}*{IF{MERGEFIELD Shift}={FILLIN "Shift to include." \o} 1 0}}= 0}
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Hi again,
Thanks for that. Before you posted again, I tried breaking down the rule for Date and Shift one at a time. The shift rule on it's own worked so I added a second SKIPIF line for the date and changed it pretty much to what you have above. This then worked as I wanted, both Shift and Date filters working but entered as 2 separate lines, not sure if that causes any other issues but seems to work fine. I will try changing back to 1 line as you have it and see how that goes. Just 1 question though, what do the '1 0' parts do? I have those missed out and it works fine so just wondering what they do. Once again thanks for the help. |
#6
|
||||
|
||||
Hi Tornado70,
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Thanks for explaining, makes more sense now.
Looks like all is working so thanks for all your help. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge / DSN / Data Link / MySQL | Bob Young | Mail Merge | 5 | 05-18-2012 03:44 PM |
Mail Merge - If a field is black, take the data from the row below? | mikeprent | Mail Merge | 5 | 01-05-2012 04:52 AM |
Applying Filter to mail merge crashes word!!! | sedain121 | Mail Merge | 1 | 06-28-2010 02:33 PM |
How do I set up the fields in mail merge word 07 from my data base | mbcrabber | Mail Merge | 4 | 06-06-2010 01:25 PM |
Need help creating a data base for mail merge. | acedking90 | Mail Merge | 0 | 07-27-2009 11:04 AM |