View Single Post
  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default lineing up data from access in a column in word

How about the following:

You clcik the Show/Hide button (the pilcrow or reverse P) to show
formatting characters such as tabs and paragraph marks

You insert the following nested field codes:

{ IF "{ MERGEFIELD Discrepancy }" = "" "" "Discrepancy:tabenter
{ MERGEFIELD Discrepancy }enter
" }

where instead of tab you press the Tab key, and instead of enter you
press the Enter key. You should then see a 3-line IF field with a tab
and paragraph mark at the end of line one, and a paragraph mark at the
end of line two.

Select the first line of the IF field and use Format-Paragraph-Tabs to
set a Left tab of 2in (or 5cm, say). This is just as an example.

Select the paragraph mark at the end of the first line and use
Format-Font to set it to Hidden

Select the second line of the IF field and use format-Paragraph to set
the left indent to 2in/5cm

Merge to a new document. You will probably see something like

Discrepancy
Line 1
Line 2
Line 3

Now click the Show/Hide button while the new document is visible. With
any luck you will see this change to something like

Discrepancy Line 1
Line 2
Line 3

If so, duplicate that first IF field and change the names so you have e.g.

{ IF "{ MERGEFIELD Discrepancy }" = "" "" "Discrepancy:tabenter
{ MERGEFIELD Discrepancy }enter
" }{ IF "{ MERGEFIELD Crossbite }" = "" "" "Crossbite:tabenter
{ MERGEFIELD Crossbite }enter
" }{ IF "{ MERGEFIELD Overbite }" = "" "" "Overbite:tabenter
{ MERGEFIELD Overbite }enter
" }

and so on. Try the merge again.

I have only tried this with small data volumes on Word XP but it does
seem to work. I suspect anything else is going to be considerably harder.



Peter Jamieson

http://tips.pjmsn.me.uk

magicdds wrote:
This was just an illustration. There are actually 25 fields to deal with.
This would present with too many possible tables to create. The other problem
with tables is that the printout has an extra blank line inbetween each row.
You said that there were other possible approaches. Do any of the other
approaches not involve the use of tables?

Thanks for your help.
Mark



"Peter Jamieson" wrote:

Do you actually have just these 4 fields, or is this just an illustration?

If it is just 4, there are 16 possible table layouts starting from "no
table" (all the fields are blank) to a four-row table (all the fields
are non-blank). In that case it is just about practical to have 16 IF
fields, each of which inserts the table you need. If one or more of the
fields is always non-blank, the numer of possible combinations you have
to deal with is obviously reduced. You can make it slightly easier to do
the IF field by doing something like

{ IF { MERGEFIELD Discrepancy } = "" { SET D "Y" } { SET D "X" }
}{ IF { MERGEFIELD Crossbite } = "" { SET C "Y" } { SET C "X" }
}{ IF { MERGEFIELD Overbite } = "" { SET O "Y" } { SET O "X" }
}{ IF { MERGEFIELD "Other Problems" } = "" { SET P "Y" } { SET P "X" }
}{ SET DCOP "{ REF D }{ REF C }{ REF O }{ REF P }"
}{ IF "{ REF DCOP }" = "XXXX" "" ""
}{ IF "{ REF DCOP }" = "XXXY" "put a 1-row table with the 'Other
problems' field here'" ""
}{ IF "{ REF DCOP }" = "XXYX" "put a 1-row table with the 'Overbite
field here'" ""
}{ IF "{ REF DCOP }" = "XXYY" "put a 2-row table with the 'Overbite'
and 'Other problems' fields here'" ""
}

and so on.

If you have 5 or more fields, things obviously become much more
difficult. There are other possible approaches, but let's see if the
above can work for you first.


Peter Jamieson

http://tips.pjmsn.me.uk

magicdds wrote:
I have data in Access that might look as follows for a patient:

Discrepancy = Response1 LF Response2 LF Response3
Crossbite = Response4 LF Response5
Overbite =
Other Problems = Response6 LF Response7 LF Response8

where LF is a "line feed"


In my word document I am doing the following:

If {Mergefield{Discrepancy} "" "{Advance \x15}Arch Discrepancy: {Advance
\x200} Mergefield{Discrepancy}" ""}
If {Mergefield{Crossbite} "" "{Advance \x15}Crossbite: {Advance \x200}
Mergefield{Crossbite}" ""}
If {Mergefield{Overbite} "" "{Advance \x15}Overbite: {Advance \x200}
Mergefield{Overbite}" ""}
If {Mergefield{Other Problems} "" "{Advance \x15}Other Problems: {Advance
\x200} Mergefield{Other Problems}" ""}


I would like the printout in Word to look as follows:

Discrepancy: Response1
Response2
Response3
Crossbite: Response4
Response5
Other Problems: Response6
Response7
Response8

Instead, what prints is as follows:

Discrepancy: Response1
Response2
Response3
Crossbite: Response4
Response5
Other Problems: Response6
Response7
Response8

I tryed to use a table to print the results but this presented with two
problems:
1) a row was created in the table for OVERBITE, which was blank since
overbite had no responses
2) After each row in the table, there was an extra blank line that I could
not eliminate.This spread out the information on the paper over too much
space and did not look very professional.
So the table route did not work.

I tried to figure out how to use a hanging indent to get things to print out
correctly, but I couldn't figure out how to apply the hanging indent only to
the responses.

Can anyone help with how to set up this form letter.

Thanks,
Mark