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
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