Importing form data to database

K

Kozmo

greetings;
I am making a form using W2000 that I will use to collect data and export to a database. The problem I have is it seems the only way to export data from form fields is into a comma-delimited file. Since a few of my fields are "free form" comment fields, I will likely have extra commas scattered throught the fields and these will throw data into wrong fields in the database and/or drop data because the database sees too many fields.

Is there a way to use another character for field delimitting or another solution to this?

thanks; Kozmo
 
D

Doug Robbins - Word MVP

Hi Kozmo,

The following code should create a string containing the .Result of each
formfield separated by a tab that you may be able to import directly into
your database.

Dim source As Document, target As Document, aff As FormField, myrecord As
String
Set source = ActiveDocument
Set target = Documents.Add
myrecord = ""
For Each aff In source.FormFields
myrecord = myrecord & vbTab & aff.Result
Next aff
myrecord = Mid(myrecord, 2) 'delete the initial tab
target.Range.InsertBefore myrecord

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP
greetings;
I am making a form using W2000 that I will use to collect data and export to
a database. The problem I have is it seems the only way to export data from
form fields is into a comma-delimited file. Since a few of my fields are
"free form" comment fields, I will likely have extra commas scattered
throught the fields and these will throw data into wrong fields in the
database and/or drop data because the database sees too many fields.

Is there a way to use another character for field delimitting or another
solution to this?

thanks; Kozmo
 
K

Kozmo

thanks Doug. I'm not real savvy on this stuff. Do I take this code and
insert it into a macro to use it?

Kozmo
 
J

John Nurick

Hi Kozmo,

When you use the "Save data only for forms" option, Word creates a CSV
file in which the text fields are separated by commas and enclosed in
("delimited" or "qualified" by) quotation marks " . This makes it
possible to distinguish between commas that are field separators and
commas that are part of the data.

Most database software that can import text files (including Access)
understands this convention. Some, including Access, can also import CSV
files that have linebreaks in the data.

So you probably don't need to worry about commas in the data: but you
may have problems if it contains quotation marks. If text fields are
qualified by quotes, Access requires that quotes within the data be
doubled.



greetings;
I am making a form using W2000 that I will use to
collect data and export to a database. The problem
I have is it seems the only way to export data from
form fields is into a comma-delimited file. Since a
few of my fields are "free form" comment fields, I
will likely have extra commas scattered throught the
fields and these will throw data into wrong fields
in the database and/or drop data because the database
sees too many fields.

Is there a way to use another character for field
delimitting or another solution to this?

thanks; Kozmo

John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
 

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