Import CSV to an existing table!Help

mfaqueiroz

Registered User.
Local time
Today, 11:01
Joined
Sep 30, 2015
Messages
125
Hello,
I have a simple doubt about CSV import.
I want the user chooses the file path to be transfered to an existing table:table1.
My table1 has the following columns: Date;MachineName;Status;MachineCode;Employee;Location Code;RunTime;Maintenance.
And my input table only has Date;MachineName and Status.
I've tried the following code, but appears this error:
"Run-time error '2391' Field 'Date;MachineName;Status" does not exist in destination table "TabInst", when they exist...
Do you have ideia how can i solve that?

Sub ImportCCRLanding_Click()
Dim fileName As Variant
Dim strFileName As String
Set fileName = Application.FileDialog(msoFileDialogOpen)
If fileName.Show Then
strFileName = fileName.SelectedItems(1)
DoCmd.TransferText acImportDelim, "", "Table1", strFileName, True
End If
End Sub
 
the code is assuming your are comma deliminated, whereas looks like you have semi colons. You are not specifying an import specification - see this link

https://msdn.microsoft.com/en-us/library/office/ff835958.aspx?f=255&MSPPError=-2147217396

to create an import specification, the easiest way is to manually import from the external data tab where you can set your deliminator and save with a relevant name. Alternatively you need to create a schema.ini file

Note also that Date is a reserved word so using it may also cause unexplained erroers
 

Users who are viewing this thread

Back
Top Bottom