Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculations using Merge Fields

Status
Not open for further replies.

rayna

Programmer
Sep 24, 2001
54
0
0
CA
This is probably a terribly basic question, but I am very new to Word merge.

If I need a field in a Word Document called "Guaranteed_People" and my query contains <<guaranteed_adults>> and <<guaranteed_children>>, is there some sort of Sum() function I can use to get the result I need, or can you just simply add them together somehow?

I have looked at the Word help, and searched the Internet, so I suspect it either can't be done, or is so easy that no one can be bothered to write it down!!

Thanks in advance!
Rayna

Man plans. God laughs.
 
rayna,
Anyone who puts a closing remark (and hopefully means it) like that one is okay in my book and deserves at least one response. I don't quite understand what you desire from your output here. In a mail merge Word produces one "document" of the type you stipulate for each item in your listing for a letter, email message, envelope, etc. Thus any total you would receive would be 1 for each document if at all possible. I believe only the Catalog option might produce what you want as Word doesn't use "fields" in this manner. Further there is no real option for adding items in Word other than in tables and counting text items.
However, if your items are in fact numbers related to these categories you may want to look into using an Excel Worksheet Object inserted into your letters to display the information desired. Otherwise you can try using a Conditional Mail Merge which is not easy to setup but works and looks great when done. I searched for the link but couldn't find it. Funny I have the exact article sitting on my desk at work, but I'm not there and don't know when I might feel the urge to visit TT again. However, it still doesn't display a count directly, but you could put a field in your data source (I suggest Excel) that displays nothing for all items except the last one which would be a sum/count of the items displayed.

Hope this helps.

...btw He must really have a belly ache from all the plans of Man thus far and looking forward to more fun in the future.
 
Hi Rayna,

The syntax for adding two mergefields is:
{=«Field1»+«Field2»}

If you copy your two mergefields, «guaranteed_adults» & «guaranteed_children», and place them side-by-side wherever you need the summation, you can create the above by selecting both fields then pressing Ctrl-F9 to wrap another, empty, field around them. Then, simply fill in between the field braces so that you've got:
{=«guaranteed_adults»+«guaranteed_children»}
Press F9 to update the field, then run your merge.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top