"too few data fields" on last record

G

Gobind Khalsa

I'm trying to use data from a dbf file exported as delimited text for a mail
merge data source. Word seems to accept the file, but gives a 'record ##
contained too few data fields' errors message, where ## is always the number
of the last record in the file. Should I put an extra field delimiter at the
end of this last record? Perhaps there is no paragraph mark at the end of
the file? How can I get Word to recognize end-of-file as end-of-record?
 
G

Gobind Khalsa

More information: the record causing the error message was invisible in
notepad but showed up when I looked at the text file in Word and turned on
display of paragraph marks. The 'record' appears as a white square symbol
followed by a paragraph mark. Can I get Word to ignore this record?
 
C

Cindy M -WordMVP-

Hi Gobind,

Sounds like your database is sticking in some kind of character at the end of
the text file. Maybe Chr$(0) or some other, non-printing character. There's
no way to get Word to ignore this, you'll have to "cut it off" before opening
an existing main merge document, or before linking this to the data source.
(Or you'd need to get the program generating the text file to stop "doing
that").

Are you doing any automation (coding/scripting) in this process?
More information: the record causing the error message was invisible in
notepad but showed up when I looked at the text file in Word and turned on
display of paragraph marks. The 'record' appears as a white square symbol
followed by a paragraph mark. Can I get Word to ignore this record?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
R

Rebecca Riehm

Thanks for the reply, Cindy.

Turns out it is an ASCII code 26 (DOS EOF marker). I am exporting the data
from a DBF file using Clipper 5.3b, so it is not too surprising to find the
character there. I was just thrown that Word's default behavior didn't
handle the EOF. I added some code to the Clipper program to truncate the
offending character. It was also suggested by someone in the
comp.lang.clipper group that using the "DOS - Text" filter in Word might
have worked.

The reason I'm using a text file data source for mailmerge instead of the
DBF is because it was the only way I could find to get rid of the nagging
"Confirm Data Source" dialog box, at least that's what I hope to accomplish.
It isn't really automation if you keep bothering the user. The whole process
is controlled by a Visual Basic program.
 
C

Cindy M -WordMVP-

Hi Rebecca,

Thanks for confirming back what the problem was :) And glad you got it fixed!

I'm not sure what message you're referring to with "Confirm Data Source",
here? Which version of Word is this?
Turns out it is an ASCII code 26 (DOS EOF marker). I am exporting the data
from a DBF file using Clipper 5.3b, so it is not too surprising to find the
character there. I was just thrown that Word's default behavior didn't
handle the EOF. I added some code to the Clipper program to truncate the
offending character. It was also suggested by someone in the
comp.lang.clipper group that using the "DOS - Text" filter in Word might
have worked.

The reason I'm using a text file data source for mailmerge instead of the
DBF is because it was the only way I could find to get rid of the nagging
"Confirm Data Source" dialog box, at least that's what I hope to accomplish.
It isn't really automation if you keep bothering the user. The whole process
is controlled by a Visual Basic program.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
G

Gobind Khalsa

The 'Confirm Data Source' dialog box seems to come up when there is more
than one ODBC driver for a particular file extension. When I installed MS
Access of course I installed the Microsoft dBase drivers so that I could
import Clipper DBF files. When I installed MS FoxPro its own drivers for DBF
files were installed. That the User DSN names are different doesn't seem to
matter. I tried everything I could think of in terms of setting mailmerge
properties in the code that initiates the mail merge but nothing seemed to
prevent the dialog box from popping up. Some research on the net yielded
advice to try a text file data source, which so far seems to be working.

Some products install the Borland drivers which add to the confusion.

Any suggestions?
 
C

Cindy M -WordMVP-

Hi Gobind,

Sorry for the somewhat delayed reply - I was away last week.

If you record a macro in Word while attaching the ODBC data source you should
get code for the OpenDataSource method. You might want to try that and
copy/paste what the macro recorder yields into a follow-up message if it
doesn't work for you without the dialog box. But...

...the recorded macro to an ODBC data source *should* also include the literal
DSN name as a text string. And I would assume that would be unique for the
user profile (if you are selecting a UserDSN), or the machine (if it's a
System DSN)?
The 'Confirm Data Source' dialog box seems to come up when there is more
than one ODBC driver for a particular file extension. When I installed MS
Access of course I installed the Microsoft dBase drivers so that I could
import Clipper DBF files. When I installed MS FoxPro its own drivers for DBF
files were installed. That the User DSN names are different doesn't seem to
matter. I tried everything I could think of in terms of setting mailmerge
properties in the code that initiates the mail merge but nothing seemed to
prevent the dialog box from popping up. Some research on the net yielded
advice to try a text file data source, which so far seems to be working.

Some products install the Borland drivers which add to the confusion.

Any suggestions?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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