View Single Post
  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Suzanne Suzanne is offline
external usenet poster
 
Posts: 53
Default Help with embedded "If"

Peter,

You're a lifesaver. Look for my post "I almost have the 2-page merge" in
this thread.

When/if you open my Word doc (it's on my Office Live site:
http://suzleigh.com/MERGE.aspx), it will look a little mangled. Regardless,
I really think that I may almost have this nailed down.

I was able to get this far by creating a new column in my Excel worksheet:
"UICROOM" -- UIC & ROOM (this might be helpful for anyone in the future who
is having the same problem). On plain paper, I get exactly the results I'm
looking for. I still can't get the results on the actual form.

If you look at the form, you'll also see that I switched the pages to avoid
having to sift through rows/columns of data to get to the names listing (the
name listing is now page 1; the detailed form is page 2).

Would love your help (and/or anyone else who might be listening in).

Suz

"Peter Jamieson" wrote:

I was away for a couple of days - if you still need a solution I'll have
another look.

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

"Suzanne" wrote in message
...
After a full day of hopefully waiting for someone to tell me that there is
some method of doing what I need, I'll close this out and get on to
cutting/pasting the data for each record (sigh).

Thanks Peter for your help... Suz

"Suzanne" wrote:

I can't get this working... I've been able to get new record breaks
after
each UIC, but have yet to see just the list of names on the second page.

A simplified version of what I'm trying to get to:

First Page: UIC BLDG ROOM (followed by rows/columns of text)
Second Page: All people with the same UIC and Room (everyone in the room
will have the same building number but not necessarily the same UIC)

I can adjust the first page of the form so that one table cell will
contain
UIC, BLDG, ROOM. On the top of the second page, I need a list of names
for
that UIC+Room.

Without your help (hopefully), I'm still stuck at having to manually
Alt-Tab
between two document to cut/paste the information on the forms.

Thank you VERY much...

Suz

"Peter Jamieson" wrote:

Hi Suzanne

As Doug mentioned in an earlier thread, it's partly a question of
"where to
put your page break".

whatever you put in the TRUE result of the IF field here...

{ If { ={ COMPARE { LUIC } { MERGEFIELD UIC } }+{ COMPARE { LROOM }

{ MERGEFIELD ROOM } } } = 2
"{ MERGEFIELD UIC }{ MERGEFIELD ROOM }

" "" }

is going to appear when UIC and ROOM change (so that probably needs to
have
a page break at the end - you can insert one in the result text) and
perhaps
you will also need to repeat some of the fields at the beginning of
that new
page. i.e. you need something like

{ If { ={ COMPARE { LUIC } { MERGEFIELD UIC } }+{ COMPARE { LROOM }

{ MERGEFIELD ROOM } } } = 2
"{ MERGEFIELD UIC }{ MERGEFIELD ROOM }
whatever else you want on page 1 followed by
page break (put a real page break in here)
followed by whatever text and fields you need at the top of page 2
" "" }

At the moment, my suggestion assumes that the stuff you have in
"whatever
you want here" will be output for every record. This is because in this
kind
of merge, the first record in the group also usually contains the data
for
the first detail record in the group IYSWIM. What I am not sure about
in
this case is what you mean by...

The second page is not in a table format. Rows of names are at the
top of
the page.

Can you provide an example of the kind of layout you need to achieve?
If you
need to avoid having paragraph marks between each record, you need to
eliminate any paragraph marks in the mail merge main document that
would be
output following any of the records, and that probably also means that
you
need to insert a page break at the beginning of the "heading texts",
e.g.

{ If { ={ COMPARE { LUIC } { MERGEFIELD UIC } }+{ COMPARE { LROOM }

{ MERGEFIELD ROOM } } } = 2
"page break{ MERGEFIELD UIC }{ MERGEFIELD ROOM }
whatever else you want on page 1 followed by
page break (put a real page break in here)
followed by whatever text and fields you need at the top of page 2
" "" }

If you need to eliminate the page break on page 1, try

{ If { ={ COMPARE { LUIC } { MERGEFIELD UIC } }+{ COMPARE { LROOM }

{ MERGEFIELD ROOM } } } = 2
"{ IF { LUIC } "" "page break" "" }{ MERGEFIELD UIC }{ MERGEFIELD
ROOM }
whatever else you want on page 1 followed by
page break (put a real page break in here)
followed by whatever text and fields you need at the top of page 2
" "" }

NB, you cannot eeliminate the final paragraph mark on a page, but a
directory merge does not insert that one in the output anyway, i.e. if
your
mail merge main document just ha

{ MERGEFIELD UIC }

and nothing else except that final para, your output would have

UIC1UIC2UIC3UIC4...

You may find in practice that this introduces other problems (for one
thing,
I hope I have the logic the right way around!) but try it anyway.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Suzanne" wrote in message
...
Thanks! The third one did it (I didn't try the other two). You are
correct
in that none of the fields are empty.

I've given up hope on this, but here's one last shot... now that the
data
is
in Word, is there anyway to automate my Word form with these results?
I
was
told I couldn't do it straight from Excel.

I have a two-page form with numerous table columns and rows. The
UIC,
Building, and Room go on the top of the first page. Names which are
associated with that UIC/Bldg/Room combination go on the second page.

The second page is not in a table format. Rows of names are at the
top of
the page.

I'm ready to conclude that despite the great things that Word can do,
I
may
have to manually align, cut/paste, and validate data on the form I'm
required
to use.

Suz

"Peter Jamieson" wrote:

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.