PDA

View Full Version : Solved: Merge field question: handling blank data



xCav8r
06-03-2005, 09:11 AM
Perhaps making a line break isn't the best way to go about this, but it's what came to mind. I need to set up an address block that doesn't have blank lines when there's no data in the field for a record. My thought is to include a line break in an IF field. If it's not blank, then line break and include data from field. If it's blank, don't do anything. Problem is I can't figure out how to stick a line break in a field. Any ideas?

xCav8r
06-03-2005, 09:40 AM
I think I figured it out. I created an autotext entry for a line break, and then I can insert that into an IF field.

MOS MASTER
06-03-2005, 09:45 AM
Hi, :yes

This is not that hard to do buth it's difficult for me to explain cause my Office is Dutch! (Damn..should buy me a UK version as well)

Ok for exercise:

Create a excel file
Column A head is : "Name"
Column B head is : "LastName"
Fill in 2 names under Name and Fill in one Last name under LastName
Close and save the file
__________________________________________________
Create new Word file
Go to view/toolbarst/mailmerge
Connect the excel file (I think you know how)
Now Insert the 2 fields next to each other. Important: Realy next to each other with no Spaces between them should look like:

<<Name>><<LastName>>
Now put your cursor between the 2 field code and choose "Word-Insert field" (Dropdown on toolbar)
Choose "IF...Then...Else"
In Fieldname choose "LastName" in the Dropdown
In Equation choose "Is not Empty"
In the textbox "Insert this text": Put your Cursor in there and just hit the ENTER button to get a VbCr in to the field! (The cursor should be on the seccond line in the textbox)
Don't do anything with the second Textbox!
Press Ok The If Field is inserted and the Total Fieldcode would look like this: (ALT+F9)

{ MERGEFIELD Name }{ IF { MERGEFIELD LastName } <> "" "
" "" }{MERGEFIELD LastName }

So in the field you really don't see a specif caracter to tell the vbCr is there. (But believe its there)
No Press the <<ABC>> button to view the merge data
Use the < back and > forward record buttons to go true your merged data to see the Enters are filled in for only those cases where you have a last name!
Conclusion: You should put in such an If statement for every field you want an enter to follow if the field is NOT empty and else do nothing.

Have fun playing with it! :whistle:

MOS MASTER
06-03-2005, 09:46 AM
I think I figured it out. I created an autotext entry for a line break, and then I can insert that into an IF field.
Seams to much work and could be unreliable try my tip! :yes

xCav8r
06-03-2005, 09:54 AM
I feel silly now for having figured that out on my own. Anyway, thanks a bunch. This was exactly what I was looking for.

MOS MASTER
06-03-2005, 09:59 AM
You're welcome! :beerchug:

xCav8r
06-03-2005, 11:23 AM
Hmmm...after looking at this more closely, I see that the IF...THEN...ELSE just does what I was typing manually except that you hit return instead of using autotext which was a completely unnecessary step. I'm not sure that I follow about the vbCr. This isn't code. It's just a normal carriage return or line break with the standard word symbol for it, no?


{ IF { MERGEFIELD COVERLTR } <>"" "
NOT BLANK" "BLANK" }

as opposed to


{IF {MERGEFIELD COVERLTR } <>"" "{ AUTOTEXT LINEBREAK }NOT BLANK" "BLANK" }

MOS MASTER
06-03-2005, 11:41 AM
Hi, :yes

I know you know VBA and couldn't find the proper Word but Yes VbCr is the same as: "carriage return"

Sorry for the confusion...BTW don't know why you need the Blank/Not Blank lines in your Field code?? (They don't come out over here when I choose Is Not Empty (Or Is Not Blank...I explained I have a Dutch version))

The field code I posted works correct over here? Have you done exactly as I described??

:whistle:

xCav8r
06-03-2005, 11:55 AM
Ok, thanks for the explanation of the vbCr. Thought I might be missing something.

I put the words BLANK and NOT BLANk in there for readability for the post. Looks like it had the opposite effect. ;)

I didn't do exactly as you described, no, but I know how to produce the same result. You see, I wasn't aware of the existance of the dialog box that guides users through using an IF field. I was just hitting CTRL+F9 and typing it manually, and it just didn't occur to my small brain to just hit return there, which is the same thing as doing it in the IF...THEN...ELSE dialog box, which I learned after trying it after you had suggested it. That'll come in handy when working with others in the future, so I'm glad I learned about it.

MOS MASTER
06-03-2005, 11:58 AM
Thanks for clarifying...yeps somethimes it get's confusing when not writing in ones native language....:rofl:

Glad I could help....:whistle: