import csv conversion & import spec error


M

Maver1ck666

I need to import a .csv file into an Access 2003 database.

One of the columns in the .csv holds both numeric and text datatypes so I
have set the import table to text.

The problem is this! If I import the table manually creating an import spec,
the import goes fine and all the data is imported with no conversion type
errors. As soon as I try using the automatically importing the .csv, the
numeric values are imported (as that's what appears first) and the text
values are dropped resulting in an import error table being created.

If I then try it again using the spec but manually, it works fine.

The code I am using is this:

If strFile = "SLAC.csv" Then

strStatus = "Importing SLAC data..."
varStatus = SysCmd(acSysCmdSetStatus, strStatus)

strTable = "TblImportSLAC"

strPathFile = strPath & strFile
DoCmd.TransferText acImportDelim, SLACImportSpecification,
strTable, strPathFile, blnHasFieldNames

strStatus = " "
varStatus = SysCmd(acSysCmdSetStatus, strStatus)

strFile = Dir()

End If

Is there a problem with my code? I can't understand why it is failing when
run via the code.

Cheers in advanced for your help!

Ben
 
Ad

Advertisements

M

Maver1ck666

Ignore me people, I've just realised I hadn't put the inport spec in quote
marks. Just done it and it now seems to work!

Thanks anyway!
 

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