lineing up data from access in a column in word

M

magicdds

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
 
P

Peter Jamieson

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
 
M

magicdds

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
 
D

Doug Robbins - Word MVP on news.microsoft.com

The alternative that I would consider first would be to use an Access report
rather than mailmerge.

Only after I had convinced myself that an Access report was not possible, I
would then use visual basic to iterate through the data in Access and create
a document with the required layout in Word, formatting each of the
paragraphs with a hanging indent and using the Replace() function to replace
the <LF> with <TAB><LF>

Another approach could be after executing the merge to a new document, use a
macro that makes use of the Edit>Find ability of Word to look for each of
the headings and then apply the necessary formatting.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
P

Peter Jamieson

You said that there were other possible approaches. Do any of the other
approaches not involve the use of tables?

The main other approaches that I had in mind would involve the creation
of an intermediate data source, but it might not solve the "extra line"
problems you report. I'll have to have a look.

I take it that you considered Doug's suggestions?

Peter Jamieson

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

Peter Jamieson

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:<tab><enter>
{ 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:<tab><enter>
{ MERGEFIELD Discrepancy }<enter>
" }{ IF "{ MERGEFIELD Crossbite }" = "" "" "Crossbite:<tab><enter>
{ MERGEFIELD Crossbite }<enter>
" }{ IF "{ MERGEFIELD Overbite }" = "" "" "Overbite:<tab><enter>
{ 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top