There have been a lot of posts on Run-time error 2391 but I have never seen an answer to it:
This produces an error: Field 'F1' doesn't exist in destination table "TBL_AR_AGING"
The field names are the same in the excel spreadsheet as the table (in fact the table was made from an import of the same file), there are no spaces in the directory of strInputFileName, I've tried every Excel type (4 through 9), and when I import the excel file by going through the wizard it works every time - just not via VBA code.
Any help would be appreciated.
Code:
Private Sub CMD_IMPORT_NEW_DATA_Click()
Dim varDate As String
Dim varSpecification As String
Dim varTable As String
Dim strInputFileName As String
varTable = "TBL_AR_AGING"
varDate = Format(Format(Now(), "DDMMMYYYY_HhMmSs_AMPM"), ">")
strInputFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
DialogTitle:="Please select the excel file you want to import...", _
Flags:=ahtOFN_HIDEREADONLY)
If (strInputFileName & "") = "" Then
Else
'strInputFileName = Chr(34) & strInputFileName & Chr(34)
DoCmd.OpenQuery "QDEL_AR_AGING"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, varTable, strInputFileName
End If
This produces an error: Field 'F1' doesn't exist in destination table "TBL_AR_AGING"
The field names are the same in the excel spreadsheet as the table (in fact the table was made from an import of the same file), there are no spaces in the directory of strInputFileName, I've tried every Excel type (4 through 9), and when I import the excel file by going through the wizard it works every time - just not via VBA code.
Any help would be appreciated.