Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jul 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    57
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    Edited by HansV to replace PDF attachment with picture - saves the reader a few clicks

    I'm trying to import a csv file into a predefined table. The csv file was created by exporting data from an Oracle database. I have a simple automated procedure to import the file from a command button:

    On Error GoTo HandleErr

    Dim Response As String, stTableName As String, Msg As String, stFileName As String
    stTableName = Me.TableName
    stFileName = Me.ImportFileName

    If IsNull(Me.TableName) Then
    Msg = MsgBox("Please enter a table name to import to (ie. tblPP)", vbOKOnly)
    GoTo ExitHere
    End If

    DoCmd.TransferText acImportDelim, , stTableName, stFileName, True
    Response = MsgBox("Import Completed Successfully", vbOKOnly, "Records Import")

    ExitHere:
    Exit Sub

    HandleErr:
    Select Case Err.Number
    Case 94
    Msg = MsgBox("Please enter a table name to import to (ie. tblPP)", vbOKOnly)
    GoTo ExitHere
    Case Else
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, "frmMenu.cmdImportFile_Click"
    End Select

    I'm getting Error 2391: Field '???' doesn't exist in destination table 'tblLP.'. (See the attached a pdf with the actual screen shot of the error because the field name shown has weird characters and I have no idea where it's getting this from.) I have checked the csv file header line to the field names in the table and they all match. I can import the file manually by using File, Get external data etc with no error. Any ideas?
    Attached Images Attached Images
    • File Type: png x.png (8.0 KB, 0 views)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    Could you create a copy of the .csv file, remove all data records so that only the line with field name remains, zip it and attach it to a reply?

  3. #3
    Star Lounger
    Join Date
    Jul 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    57
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    Here is the header file.
    Attached Files Attached Files

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    I can confirm the error message - I see it too. I'll try to find out what causes it...

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    Well, I don't know the cause of the problem, but I found how you can work around it: using an import speciifcation.
    Start importing the file manually, using File | Get External Data | Import...
    When you get to the last step of the Import Text Wizard, don't click Finish, but click Advanced instead.
    Click Save As...
    Provide a name for the import specification, e.g. MyImportSpec (or accept the name proposed by Access).
    Click OK.
    You don't need to finish the import, you can cancel it now.
    In your code, change the line

    DoCmd.TransferText acImportDelim, , stTableName, stFileName, True

    to

    DoCmd.TransferText acImportDelim, "MyImportSpec", stTableName, stFileName, True

    using the name that you gave the import specification.

    The code should work now.

  6. #6
    Star Lounger
    Join Date
    Jul 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    57
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    Thanks Hans... that did work. I have used import specs in the past but didn't think to try that to get around the problem. Strange error though, would like to know where it was getting that weird field name from. Maybe someday....

    Thanks again!

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Importing csv - Error 2391 (2003/SP2 (11.6566.8132))

    I'd like to know the cause too, but it'd probably take too much time to investigate <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •