I just try to import a .csv file with vba. I use the DoCmd.TransferText method with custom specs. I tried to import the file with the wizard, with the same specs and it works perfectly fine.
But when I start the vba I get this error Message:
Sorry, it is in german, but I think one can read the essentials
Here is the part of my code, where I call up the method:
Public Function ImportFileToTable(params As ImportFileToTableParams) As ImportFileToTableResult
'TODO: Import a CSV File into the selected table
Dim result As New ImportFileToTableResult
On Error GoTo ImportFail
DoCmd.TransferText acImportDelim, params.SpecificationName, params.TableName, params.FileName, params.HasFieldNames
result.Success = True
Set ImportFileToTable = result
Exit Function
ImportFail:
result.Success = False
result.ErrorMessage = "There was an error importing the File"
Set ImportFileToTable = result
End Function
My Database is on a Network-Drive, but I tried to copy it on my local drive and it had the same otcome. I also experimented with the File Location.
The Software I am using is: -Microsoft Access 2013
Thank you all in adnvance :)