Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lbmmoh lbmmoh is offline
external usenet poster
 
Posts: 1
Default How to write {} statments with IF MAILMERGE?


Im a newb here, and trying to write a mailmerge that pulls data from an
excel file.

I have it working, but I get blanks in my letter where the recipient
isnt making that purchase.

for example right now I have lots of items that dont always get filled
because they are blank in my database:

Hello thanks for your order:

{MERGEFIELD "Item1"}
{MERGEFIELD "Item2"}
{MERGEFIELD "Item3"}

Your order will be shipped out ASAP.

If I have a customer with just Item1 purchase, then there is a 2 blank
lines before the "Your order..." line starts. I understand that I need
an IF statment to get rid of the gap but I dont know how to write it. I
see that I have to hit control f9, but when I do that after my current
MERGEFIELD, I get too many of the {} symbols.

My question is simply trying to understand how to use the control F9
and when to do it, so that I have the right amount of symbols.

The code should look like:

{MERGEFIELD "Item1"}{ }{IF {MERGEFIELD "Item1"} ""
etc
etc

But again, I cant get the right amount of { } or I get too many. Am i
missing a fundamental way in editing a MERGEFIELD that is already in my
document? Im using Word 2007

Thanks!




--
lbmmoh
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How to write {} statments with IF MAILMERGE?

While you might get by using mailmerge to do this, you should really
consider using an Access report.

However, the If...then...Else field construction with Mergefields would be

{ Mergefield "Item1" }{ IF { Mergefield "Item2" } "" [Enter]
{ Mergefield "Item2" }{ IF { Mergefield "Item3" } "" [Enter]
{ Mergefield "Item3" } "" } "" }

Where the [Enter] appears above, you need to press the Enter key at that
point when constructing the field code

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"lbmmoh" wrote in message
...

Im a newb here, and trying to write a mailmerge that pulls data from an
excel file.

I have it working, but I get blanks in my letter where the recipient
isnt making that purchase.

for example right now I have lots of items that dont always get filled
because they are blank in my database:

Hello thanks for your order:

{MERGEFIELD "Item1"}
{MERGEFIELD "Item2"}
{MERGEFIELD "Item3"}

Your order will be shipped out ASAP.

If I have a customer with just Item1 purchase, then there is a 2 blank
lines before the "Your order..." line starts. I understand that I need
an IF statment to get rid of the gap but I dont know how to write it. I
see that I have to hit control f9, but when I do that after my current
MERGEFIELD, I get too many of the {} symbols.

My question is simply trying to understand how to use the control F9
and when to do it, so that I have the right amount of symbols.

The code should look like:

{MERGEFIELD "Item1"}{ }{IF {MERGEFIELD "Item1"} ""
etc
etc

But again, I cant get the right amount of { } or I get too many. Am i
missing a fundamental way in editing a MERGEFIELD that is already in my
document? Im using Word 2007

Thanks!




--
lbmmoh



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lbmmoh[_2_] lbmmoh[_2_] is offline
external usenet poster
 
Posts: 1
Default How to write {} statments with IF MAILMERGE?


Thanks Doug,

I meant to say that my field should say:

{MERGEFIELD "Item1"}{IF {MERGEFIELD "Item1"} " " ----those
quotes should have no space, but I noticed that this site deletes it if
I dont put a space there..

What I dont get is that there are 5 brackets, but each time you hit
ctrl+F9 , you get 2 brackets. So I dont undersatnd the procedure in
building the statement itself. I already have a past Word doc that was
used with all the fields, so I think the Access will be my backup plan.




--
lbmmoh
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default How to write {} statments with IF MAILMERGE?

I suspect what Doug meant was

{ Mergefield "Item1" }{ IF { Mergefield "Item2" } "" "[Enter]
{ Mergefield "Item2" }" }{ IF{ Mergefield "Item3" } "" "[Enter]
{ Mergefield "Item3" }" }

It is easy to lose an odd bracket when typing field structures.

The structure is essentially

{ IF{ Mergefield "Item3" } "" "[Enter]
{ Mergefield "Item3" }" }

The double quotes for a nul entry are superfluous but you can include them
if you like

{ IF{ Mergefield "Item3" } "" "[Enter]
{ Mergefield "Item3" }" "" }

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


lbmmoh wrote:
Thanks Doug,

I meant to say that my field should say:

{MERGEFIELD "Item1"}{IF {MERGEFIELD "Item1"} " " ----those
quotes should have no space, but I noticed that this site deletes it
if I dont put a space there..

What I dont get is that there are 5 brackets, but each time you hit
ctrl+F9 , you get 2 brackets. So I dont undersatnd the procedure in
building the statement itself. I already have a past Word doc that
was used with all the fields, so I think the Access will be my backup
plan.



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lbmmoh[_3_] lbmmoh[_3_] is offline
external usenet poster
 
Posts: 1
Default How to write {} statments with IF MAILMERGE?


thanks again. I am able to write the same line as you but when I preview
the merge, i still have the blank spaces. THe total still shows in the
same place regardless of how many items are purchased. So situations
"a" and "b" have the same format after the merge, but I want the
spacing gone:

a)
item1
item2

Total $

b)
item1



Total $

Its that gap in situation "b" that im trying to get rid of




--
lbmmoh


  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lbmmoh[_4_] lbmmoh[_4_] is offline
external usenet poster
 
Posts: 1
Default How to write {} statments with IF MAILMERGE?


to follow up, ive ultimately trying to create a 3 column mail merge, and
I thought I could do it with zero border tables, but now that I think
about it, that would still force the structure of the mailmered
document, because the table rows would always be there even if there
was no field in a particular mergefield. Thus creating those gaps that
Im trying to remove. I want the total to get sucked up to the last item
found I attached a picture

[image:
http://images34.fotki.com/v1143/phot...xample-vi.gif]




--
lbmmoh
  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
lbmmoh[_5_] lbmmoh[_5_] is offline
external usenet poster
 
Posts: 1
Default How to write {} statments with IF MAILMERGE?


nevermind, I think I got a solution, thank you all




--
lbmmoh
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I get ..... without using the . key and can write over it? Nicci S. New Users 2 September 13th 07 04:19 AM
write with a pen Ron New Users 3 March 9th 07 03:18 AM
cannot write to cd says it is full or write protected or damaged skin0023 Microsoft Word Help 2 March 21st 06 12:56 AM
I am trying to write music in MS word. Write the words and notes B Microsoft Word Help 1 May 1st 05 11:28 PM
Nesting IF statments in BARCODE funtion.. S Stone Mailmerge 0 December 30th 04 12:53 AM


All times are GMT +1. The time now is 09:20 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"