Importing Errors

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I was having a problem with importing .dat files and Jeanette Cunningham
graciously helped me figure it out.

The code is working perfectly to automatically import the .dat file at the
push of a button. The only problem I'm having now is, when the file is
imported (as a text file) if there are errors, no messages appear to let the
user know that errors occurred during the import (like the message that
appears when you import manually).

Below is the code I'm using to import the file. I didn't DoCmd.SetWarnings
False and I've even tried putting DoCmd.SetWarning True at the beginning of
the code.

I'd appreciate any help.

Thanks,

Private Sub cmd_Import_Click()
On Error GoTo cmd_Import_Click_Err

Dim strFilter As String
Dim strInputFileName As String
Dim SourceFile, DestinationFile As String
Dim strSource As String
Dim strRenamed As String

strFilter = ahtAddFilterItem(strFilter, _
"All Files (*.*)", _
"*.*")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

'remove the file extension from strInputFileName
strSource = Left$(strInputFileName, Len(strInputFileName) - 3)
strRenamed = strSource & "txt"

SourceFile = strInputFileName ' Define source file name.
DestinationFile = strRenamed ' Define target file name.
FileCopy SourceFile, DestinationFile ' Copy source to target.

DoCmd.TransferText acImportFixed, "ERSCUST_Import_Spec",
"ERSCUST", DestinationFile

Kill DestinationFile

MsgBox "Import Complete", , "Import"

cmd_Import_Click_Exit:
Exit Sub

cmd_Import_Click_Err:
MsgBox Error$
Resume cmd_Import_Click_Exit

End Sub

--
RJF
.



Relevant Pages

  • Re: Run Time Error 53 on FileCopy command
    ... file first. ... debug, the code editor is highlighting the 'FileCopy SourceFile, ... Dim MyDay ... Dim DestinationFile As String ...
    (microsoft.public.excel.programming)
  • Re: Run Time Error 53 on FileCopy command
    ... The sheet that we're having problems with has 4 buttons ... debug, the code editor is highlighting the 'FileCopy SourceFile, ... Dim MyDay ... Dim DestinationFile As String ...
    (microsoft.public.excel.programming)
  • Re: Importing Errors
    ... Dim strInputFileName As String ... Dim SourceFile, DestinationFile As String ...
    (microsoft.public.access.externaldata)
  • RE: ADD HTML CODE
    ... SourceFile As String, _ ... Dim BullpenFile As String ... Open SourceFile For Input As F1 ...
    (microsoft.public.excel)
  • RE: Backend as email attachment
    ... Dim strpath As String ... Dim strInputFileName As String ... FileCopy SourceFile, DestinationFile ' Copy source to target. ...
    (microsoft.public.access.externaldata)