I am having an issue importing CSV files into my Access table. I am able to manually import the file using the Saved Imports but when trying to execute from VBA I run into this 31519 error. I have saved the import as a specification as well as a step. This is an example of what I am trying to do just to test the DoCmd.TransferText function. The file is a simple csv file with:
Name-ID
John-1
Doe-2
william-3
Sub import()
DoCmd.TransferText acImportDelim, "Names", "test", "C:\Users\ngrayhek\Desktop\Names\", True
End Sub
CodePudding user response:
You miss the filename:
DoCmd.TransferText acImportDelim, "Names", "test", "C:\Users\ngrayhek\Desktop\Names\Filename.csv", True
CodePudding user response:
So I found out that you must to put the file type (.csv) at the end. The last thing I discovered is that it cannot have a '\' at the end of the fileName.
Incorrect:
Sub import()
DoCmd.TransferText acImportDelim, "Names", "test", "C:\Users\ngrayhek\Desktop\Names\", True
End Sub
Corrected:
Sub import()
DoCmd.TransferText acImportDelim, "Names", "test", "C:\Users\ngrayhek\Desktop\Names.csv", True
End Sub