How to keep Access MergeField from losing formatting in Word 2003

S

Seventh.Son

I have an alphanumeric Charge number (text field) formatted with hyphens -
e.g., 21B-2009-01234. If I use that formatted field in MS Word 2003 the
hyphens are stripped out. However, if I simply copy and paste into MS Word,
the hyphens remain. There doesn't seem to be any "switch" to restore the
formatting.

Thank you.
 
G

Graham Mayor

From the Tools menu in Word, select Options and then go to the General tab
and check the box against the "Confirm conversions at open" item. (In Word
2007 it is Office Button > Word Options > Advanced > General > Confirm file
format conversion on open). Then when you attach the data source to the mail
merge main document, you will be given the option of using the DDE method of
connection which should read the data as you have it formatted in the table.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Peter Jamieson

In this type of situation I do not think the "DDE" approach works and
the simplest solution is probably to create a new query in your Access
database that takes the data that Access actually stores (i.e.
21B200901234) and re-insert the hyphens.

For example, if your data source is called mytable and the field is
called charge, your query SQL could look like

SELECT left(charge,3) & '-' & mid(charge,4,4) & '-' & right(charge,5) AS
[hyphencharge], *
FROM mytable;

Then use that query as your data source. You should be able to connect
using the default OLE DB method.

If you are not in a position to modify your Access database, you can set
up the same query in Word VBA, e.g. perhaps using

ActiveDocument.MailMerge.OpenDataSource _
Name:="the full pathname of the .mdb", _
SQLStatement:= _
" SELECT left(charge,3) & '-' & mid(charge,4,4)" & _
" & '-' & right(charge,5) AS [hyphencharge], *" & _
" FROM mytable"


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