472,127 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

Text fields from ODBC data source do not merge in Word 2000


Thank you in advance for any assistance.

I am trying to set up a mail merge from VB6/VBA code with Word 2000 using an ODBC data source (SQL 2000). I have successfully gotten the connection working using both a file dsn and a machine dsn. I am currently using a simple test merge template with fields <<FirstName>> (a nvarchar) <<Id>> (an int primary key).....plus a <<NextRecord>> field. The template doc itself has no data source attached. The code sets the data source upon calling the OpenDataSource method.

Here's the problem, when the document gets merged, the Id field merges correctly, however the FirstName does not. It just merges as a null string. I've jumped through all sorts of hoops to figure out what the problem is and here is what I've found:
-The same merge code performs correctly in Word 2007. Both the FirstName and the Id fields appear correctly in the merged document.
-Really weird: I am able to reproduce the problem in Word 2007 by leaving out the password in the DSN and being made to manually enter it at merge time. If I do that, I get a null string for the FirstName field.
-Adjusting the Format parameter of the OpenDataSource method makes no difference.
-I can view the result set correctly using the same DSN in MS Query, but upon merging into Word 2000, I still get the FirstName appearing as a null string.
-Any integer field type will merge correctly into Word 2000. Any nvarchar field type will merge as a null string.

Any ideas on how to get this merge working correctly?

Thanks again.
Aug 19 '07 #1
2 2036
14,534 Expert Mod 8TB
Have you tried changing the field to a plain varchar?
Aug 28 '07 #2
14,534 Expert Mod 8TB
Have you tried changing the field to a plain varchar?
One other thing you could try since you are using VBA is to pass the value first to a variant type variable and then into the merge.
Aug 28 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by matt tagliaferri | last post: by
3 posts views Thread by Lauren Quantrell | last post: by
5 posts views Thread by Alec | last post: by
11 posts views Thread by MLH | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.