View Single Post
  #17   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"

Hi Suzanne,

thanks for the feedback- as for the counts etc., my only suggeston is to try
to create the data source you need, including any "count" columns - it's
probably simpler than trying to add up stuff using field codes.

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

"Suzanne" wrote in message
...
Yes... the last page didn't have the notes, but this is an easy cut/past
(I
might also try putting a dummy record at the end of the worksheet). MUCH
MUCH easier to think about than having to cut/paste each section of people
into their respective rooms.

I just ran a report with nearly 200 people in different buildings, rooms,
UICs -- front and back report was 70 pages. That's 70 pages I didn't have
to
spend wearing out Alt-Tab keys!

Now that the worst is over, there's a couple of things I'll be trying out,
but won't be as frustrated with if I don't get it. You may have noticed
the
"No. CIV" "No. MIL" etc. fields at the bottom of section 2... I'm trying
out
some methods to count the number of "DAC" "AD-A" "AD-AF" in section 2 and
plunk the number into the appropriate field in section 1.

Again, you are AWESOME!! Have a GREAT weekend!!!

Suzanne

"Peter Jamieson" wrote:

Hi Suzanne

(Phew!)

If you haven't checked the very last page of output from this merge,
please
do so. If it's OK, we can all relax. Otherwise, maybe that approach I
mentioned - where the last record in each group needs to be marked -
needs
to be used. Or maybe it would be enough to add that chunk manually.

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

"Suzanne" wrote in message
...
YOU ARE AWESOME!!!!!!! I KNEW this could be done!! Thank you for not
giving up on this or telling me that what I needed to do was not
possible!

The form works PERFECTLY. I've already entered the rest of my fields
with
absolutely no problem and even restructured the first so that the UIC,
BLDG,
etc. is within the table.

This will absolutely be a 'read-only' document forever and ever (I do
NOT
want to go through this again -- although, I now know more about merge
codes
than I used to!).

THANK YOU THANK YOU THANK YOU!!!

Suzanne

"Peter Jamieson" wrote:

BTW, you may need to select the mail merge main document using e.g.
control-A and press F9 to re-execute all the fields

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

"Peter Jamieson" wrote in message
...
Can you try opening the following URL in your browser,
right-clicking
on
the link and downloading the .doc in there?

http://tips.pjmsn.me.uk/suzanne

This .doc should demonstrate the /first/ solution I suggested
(although
the layout probably needs fixing in various ways). If not, can you
please
describe what it does not do, apart from the known problem of
dealing
with
the notes in the last record.

If you would find it easier to correspond by e-mail, please despam
my
e-mail (remove KillmapS) and email me.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Suzanne" wrote in message
news I tried your last example. It's not working.

The result had the first two names at the top and did not pull
everyone
together.

I've been messing with it; at one point I had the names grouped,
but
somewhere along the line I messed that up. I'm getting a variety
of
results
as I continue to mess with this (error codes, misplaced data,
skipped
records).

At this point I'm not even working with the actual form but rather
a
plain
page test document. I think if I can get the plain page worked
out, I
can
apply it to the real thing.

Thanks -- Suzanne

I still think the answer is close.

"Peter Jamieson" wrote:

1. I think it's a bit easier to follow the logic if you stick to
using
one
local variable (and the pattern I suggested before, where you
explicitly
set
LOC to "" in that first record, then test LOC against the value of
MERGEFIELD UICROOM, and set LOC again at the end of the mail merge
main
document.

2. Because of the way this technique works, it's easiest to
imagine
that
the
list of names always comes last. Because you actually want some
notes
etc.
after the list of names, when you use this technique, you then
have
to
put
those notes at the very beginning and eliminate them when
MERGESEQ
is 1
1.
So your merge then looks something like

{ IF { MERGESEQ } = 1 "{ SET LOC "" }{ SET NOTES "" }" "" }
{ IF "{ LOC }" = "{ MERGEFIELD UICROOM }"
"{ NOTES }
your section 1 fields and table
page or {section break
your section 5 page header and column headers" "" }
merge fields you want in the list of names{ SET LOC { MERGEFIELD
UICROOM }{ SET NOTES "whatever you want in the notes at the end of
this
group of recordspage or section break }

3. The trouble with this is that the notes under your last list of
names
will never be emitted. But because of the way Word works, I don't
think
you
can logically achieve what you need without also ensuring that you
know
which the last record in each group is. If you know that, e.g.
because
you
mark the last recors in each group, you can do something more
like

{ IF { MERGESEQ } = 1 "{ SET LOC "" }" "" }
{ IF "{ LOC }" = "{ MERGEFIELD UICROOM }"
"your section 1 fields and table
page or {section break
your section 5 page header and column headers" "" }
merge fields you want in the list of names{
{ IF { MERGEFIELD LASTRECORDINGROUP } = "Y" "output your note text
here"
"" }{ SET LOC { MERGEFIELD UICROOM }

Sorry, it's now rather late here so I may not be thinking
straight,
but
Ireally think that's what you need to do.

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

"Suzanne" wrote in message
...
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