Consulting

Results 1 to 3 of 3

Thread: Solved: Error using Doccmd.transfertext

  1. #1

    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!

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,297
    Location
    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?

  3. #3

    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
  •