Solved Run time error 31519 when trying to import CSV file (1 Viewer)

AlliCarr

Member
Local time
Today, 02:47
Joined
Feb 19, 2024
Messages
60
Hi All,

I am trying to add the facility for my users to import a CSV file via a button on a form. The code in the on click event of the button is:

Code:
    DoCmd.TransferText acImportDelim, "ImportTempT", _
    "S:\IT\1 - Testing\CSVTestTwo.csv", True

But I keep getting the run time error saying 'You cannot import this file'.

The full code for the on click event of the button is below too in case that helps:

Code:
'Delete existing import info
    currentDB.Execute "DELETE FROM ImportTempT"
    
    DoCmd.TransferText acImportDelim, "ImportTempT", _
    "S:\IT\1 - Testing\CSVTestTwo.csv", True
    DoCmd.OpenQuery "OrgImportQ"
    DoCmd.OpenQuery "ContactImportQ"
    
        Me.Requery
    MsgBox "Import complete"

Any help is much appreciated.
 
First of all, you should always use correct and complete syntax.
DoCmd.TransferText (TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)
 
First of all, you should always use correct and complete syntax.
DoCmd.TransferText (TransferType, SpecificationName, TableName, FileName, HasFieldNames, HTMLTableName, CodePage)
Thanks @ebs17 It works perfectly since I added in the additional comma to represent the specification name! :)
 

Users who are viewing this thread

Back
Top Bottom