Help Importing Data to New Table

  • Thread starter Thread starter Andibevan
  • Start date Start date
A

Andibevan

Hi All,

I have a csv file that I am trying to import using VB. The CSV file has
around 25 fields and the headings are contained within the first row.

How would I create a new table and then import this data into the new table.

Any pointers would really be appreciated as I can't find anything to import
CSV files into a NEW table.

Thanks in advance.

Andi
 
Hi Andi,

One way is simply to use DoCmd.TransferText acImport. If the table name
you supply does not already exist, Access will create a new one, taking
the field names from the first line of the text file. This normally
works just fine; the main exceptions are
-where a field contains numeric values in the first records but some
non-numeric ones lower down: Access assumes it's a number field and than
can't import the non-numeric values
-where a field contains dates or times in a format that Access doesn't
recognise as date/time values,
and there are ways round these.

However, if your proposed database operations include routinely creating
new tables as new data comes to hand, it's probably a sign that your
data structure is flawed. Obviously I don't know anything about your
data, but a common technique is to link (rather than import) CSV files
(using DoCmd.TransferText acLink) and then use queries to move the data
into your standard table structure, munging it as necessary on the way.
 
Back
Top