Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2000
    Location
    Massachusetts, USA
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Import Text File Error (Access 2000)

    I am using the Transfer Text process to import a text file. Occasionally the Text file will be empty and I get an "Query must have at least one destination field" error followed by "Action Failed - Halt".

    Is there a way around this as an empty text file will some times be legitimate.

    Thanks.

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

    Re: Import Text File Error (Access 2000)

    Note the number of the error you get. Put error handling in your code to avoid the error message. Say that the error you get has number 3066:

    Sub ImportTextFile()
    On Error GoTo ErrHandler

    ...
    DoCmd.TransferText ...
    ...
    Exit Sub

    ErrHandler:
    Select Case Err.Number
    Case 3066
    ' Text file was empty; ignore this
    Resume Next
    Case 3024
    ' Text file not found, display custom message
    MsgBox "Where is that text file?"
    Case Else
    ' All other errors
    MsgBox "Error " & Err.Number & " occurred, with message:" & vbCrLf & Err.Description
    End Select
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Schenectady, New York, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import Text File Error (Access 2000)

    PeteQ

    Try using a function like this. ( I converted a macro to a module using Save As).


    '------------------------------------------------------------
    ' Macro1
    '
    '------------------------------------------------------------
    Function Macro1()
    On Error GoTo Macro1_Err
    Dim resp As String
    Dim num As String

    DoCmd.TransferText acImportDelim, "", "tbljeb", "c:/me", False, ""


    Macro1_Exit:
    Exit Function

    Macro1_Err:
    resp = Err.Description
    num = Err.Number

    If num = "3066" Then
    Resume Macro1_Exit
    End If

    MsgBox Error$
    Resume Macro1_Exit

    End Function
    Don
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18> <img src=/S/flags/NewYork.gif border=0 alt=NewYork width=30 height=18> "Life on Earth is expensive, but at least it includes a free trip around the Sun."

  4. #4
    New Lounger
    Join Date
    Dec 2000
    Location
    Massachusetts, USA
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Import Text File Error (Access 2000)

    Thanks to both of you.

Posting Permissions

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