-
Solved: Error using Doccmd.transfertext
Hi,
I am trying a sample program to transfer contents from a delimited file into a table in access. This is the code I am using:
Sub importfile()
On Error GoTo ferrors
Dim db As database
Dim rec As Recordset
DoCmd.TransferText acImportDelim, , "tblDet", "C:\Anand\Ebook\practice\Access\test.csv", yes
Set db = CurrentDb()
Set rec = db.OpenRecordset("tblDet")
ferrors:
Debug.Print ("sub importfile: " & Err.Number & ": " & Err.Description)
End Sub
This is the error message I am getting:
sub importfile: 2391: Field 'F1' doesn't exist in destination table 'tblDet.'
tbldet has the following structure
Name Emp No Age
(and values for these fields)
This is what test.csv contains:
Name Emp No Age
(and values for these fields)
Please help me debug this error. Thanks!
-
That error usually occurs because Access has come across some data that does not fit in with your field names and has assigned it the value of F1.
Perhaps one or more lines in the file have more commas than others.
Have you checked out the data to see if there is anything obvious?
-
Thanks
Was able to figure it out. Needed to give the import specification
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules