Here's something out of an app I happen to be working on right now:
Code:
Dim db As DAO.Database
On Error GoTo ErrorHandler
Set db = CurrentDb
db.Execute "DELETE * FROM tblImportedRecords"
If Len(Dir(g_sExcelPath & "Vehicle Trip Charge Detail.csv")) > 0 Then
DoCmd.TransferText acImportDelim, "AVI3", "tblImportedRecords", g_sExcelPath & "Vehicle Trip Charge Detail.csv", True
DoEvents
Kill g_sExcelPath & "Vehicle Trip Charge Detail.csv"
Else
MsgBox "Target file does not exist"
GoTo ExitHandler
End If
'append data from imported table to production table
db.Execute "qryAppendImportedData", dbFailOnError
MsgBox "Import complete"
ExitHandler:
Set db = Nothing
Exit Sub
ErrorHandler:
Select Case Err
Case Else
MsgBox Err.Description
DoCmd.Hourglass False
Resume ExitHandler
End Select
If memory serves, I created the import specification ("AVI3") while manually importing the file to a new local table the first time.