View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Help with embedded "If"

Assuming you're doing a "one-many" type merge
There are at least two problems in your current code:
a. you can't do the AND the way you are trying to do it at the moment
b. you seem to be inserting the same thing whether UIC and ROOM change or
not.

If you only want to test for a change in either UIC or ROOM, you can try

{ IF { MERGESEQ } = "1" "{ SET LUIC "" }{ SET LROOM "" }" ""
}{ If "{ LUIC }{ LROOM }" "{ MERGEFIELD UIC }{ MERGEFIELD ROOM }"
"{ MERGEFIELD UIC }{ MERGEFIELD ROOM }

" "" }whatever you want here
{ SET LUIC { MERGEFIELD UIC } }{ SET LROOM { MERGEFIELD ROOM } }

or perhaps even just

{ IF { MERGESEQ } = "1" "{ SET UICROOM "" }" ""
}{ If "{ UICROOM }" "{ MERGEFIELD UIC }{ MERGEFIELD ROOM }"
"{ MERGEFIELD UIC }{ MERGEFIELD ROOM }

" "" }whatever you want here
{ SET UICROOM "{ MERGEFIELD UIC }{ MERGEFIELD ROOM }" }

If you are trying to check that both UIC and ROOM have changed, try

{ IF { MERGESEQ } = "1" "{ SET LUIC "" }{ SET LROOM "" }" ""
}{ If { ={ COMPARE { LUIC } { MERGEFIELD UIC } }+{ COMPARE { LROOM }
{ MERGEFIELD ROOM } } } = 2
"{ MERGEFIELD UIC }{ MERGEFIELD ROOM }

" "" }whatever you want here
{ SET LUIC { MERGEFIELD UIC } }{ SET LROOM { MERGEFIELD ROOM } }

All the above assume that UIC and ROOM are never ""

--
Peter Jamieson
http://tips.pjmsn.me.uk

"Suzanne" wrote in message
news

I'm trying to merge Excel data to Word based on two values: "UIC" and
"Room"

{IF {MERGESEQ } = 1 ""}
{ SET UIC1 { MERGEFIELD UIC }}
{ SET ROOM1 { MERGEFIELD ROOM }}
{ IF { UIC2 } { UIC1 } { AND { IF { ROOM2 } { ROOM1} }}
"{MERGEFIELD UIC } { MERGEFIELD ROOM } {MERGEFIELD LAST }"
"{MERGEFIELD UIC } { MERGEFIELD ROOM } {MERGEFIELD LAST }"
{ SET UIC2 {MERGEFIELD UIC } {SET ROOM2 {MERGEFIELD ROOM } }}

This is partially working:

- It's skipping records
- Where each skipped record is supposed to be, there's an "Error!
Bookmark not defined" message.