Link to home
Start Free TrialLog in
Avatar of lurch36
lurch36

asked on

Mail Merge Template - last record in datasource?

There may be another way around this, so I'll explain my dilemma before jumping into the question...

I'm trying to do a mail merge where I have some header information, some detail information and then a closing.  

This isn't exactly what I'm doing, but a simple example would be something like:
-------------------------------------------
Name: [Fred Bloggs]

Subject    Grade
[Physics]   [A]
[Chemistry] [A-]
[English]   [B+]

Well done [Fred], keep up the good work!
-------------------------------------------
...where the bits in [] are values from data fields (and we're only dealing with records for Fred Bloggs - no other students are involved, and the number of subjects is variable)

An MSDN search has suggested that I should be able to achieve this by setting it up as a Catalog merge type (to do the "Subject/Grade" detail part), and using {IF {MERGESEQ} = "1" ....} syntax in the template to do the header bit (from "Name:" through to the subject/grade table heading).

All of that works fine!
The trouble I have is trying to get the closing in - if it was just text, I could put it in the page footer or something I'm sure, but it uses a data field, and so I need to do it when I reach the last record - but how can I tell, within the template, that I have reached the last record of the datasource? (BTW - I'm using Office 97)
Or alternatively, how else could I get the closing in?
Avatar of Anne Troy
Anne Troy
Flag of United States of America image

Potential only: Try putting your closing into a table cell, or putting the grades part in one table cell and the closing in another.
Avatar of lurch36
lurch36

ASKER

I tried that (both options), but it didn't work...
Using my simplistic example again, the effect that both of these have is as follows:
-------------------------------------------
Name: [Fred Bloggs]

Subject    Grade
[Physics]   [A]

Well done [Fred], keep up the good work!
[Chemistry] [A-]

Well done [Fred], keep up the good work!
[English]   [B+]

Well done [Fred], keep up the good work!
-------------------------------------------
ASKER CERTIFIED SOLUTION
Avatar of Anne Troy
Anne Troy
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lurch36

ASKER

Thanks for your help Dreamboat.
It turned out that between the time I registered the question and read your answer, it was decided to do this one (and some others) in Crystal Reports instead of Word, so my question is no longer relevant.  However, I do have other Mail Merge things to do, and that web-site you pointed me to is quite good and comprehensive, so you can have the points and an "A" anyway!
Why, thank you, sir!