I am working to automate an import. I have defined the import specification and it works if I run it manually but it fails when called by VBA.
The line that produces the error is in red.
Run-time error 2391
Field 'F1' doesn't exist in destination table 'Import'
Code:
Public Function SelectFile(Optional ByVal sFilter As String) As String
'Microsoft Office Object Library - Reference
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.AllowMultiSelect = False
.Title = "Please select a folder"
.Filters.Clear
If .Show = True Then
SelectFile = .SelectedItems(1)
End If
End With
Set fDialog = Nothing
End Function
Public Sub Import_Python()
Dim strFile As String
strFile = SelectFile()
[COLOR=red]DoCmd.TransferText acImportDelim, Python_Import_Spec, "Import", strFile, False[/COLOR]
End Sub
Run-time error 2391
Field 'F1' doesn't exist in destination table 'Import'