I am using this code to import and append data to an existing table in Access 2010:
Private Sub ImportCarcassA_Click()
If IsNull(Me.txtFileName) Or Len(Me.txtFileName & "") = 0 Then
MsgBox "Please select the Excel file"
DoCmd.TransferSpreadsheet acImport, 10, "data_Carcass", Me.txtFileName, True
Me.ImportCarcassA.Enabled = False
The problem is:
The Access table ("data_Carcass") contains some fields formatted as text. The input file I am attempting to append contains both integer and text values in these fields. When I attempt to import, I get a table of errors for all text values in these fields. It is as if Access is recognizing these fields as integer and attempting to append as integer rather than text. It is probably because the first several lines of the input file do not contain any text values.
How can I modify my VBA code to ensure these fields are imported as text regardless of the data type that the first several lines of the input file contains?