I am trying to import a spreadsheet to a table.
On my computer, it works fine.
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Data", myFileName, True
True being the "HasFieldNames" parameter
I copy this file onto another machine and it no longer assigns field names. It imports the field names as data and calls the fields F1, F2, etc. with an empty record as the first record.
What is going on? Am I doing something wrong? Is there a work around? I need column headers because I use the field name in a query a couple of lines down in the code. Any suggestions?
My Versions
Microsoft Access 2000 (9.0.6926 SP-3)
Microsoft Excel 2000 (9.0.6926 SP-3)
Other PC versions
Microsoft Access 2000 (9.0.3821 SR-1)
Microsoft Excel 2000 (9.0.3821 SR-1)
The function is below.
Any suggestions on what may be interfering?
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Text0.SetFocus
myFileName = Text0.Text
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "Data"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Data", myFileName, True
mySQL = "DELETE Data.* FROM Data WHERE (((Data.ITEMNUM) Is Null))"
DoCmd.RunSQL mySQL
DoCmd.SetWarnings True
Form_ImportList.Visible = False
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
PB
On my computer, it works fine.
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Data", myFileName, True
True being the "HasFieldNames" parameter
I copy this file onto another machine and it no longer assigns field names. It imports the field names as data and calls the fields F1, F2, etc. with an empty record as the first record.
What is going on? Am I doing something wrong? Is there a work around? I need column headers because I use the field name in a query a couple of lines down in the code. Any suggestions?
My Versions
Microsoft Access 2000 (9.0.6926 SP-3)
Microsoft Excel 2000 (9.0.6926 SP-3)
Other PC versions
Microsoft Access 2000 (9.0.3821 SR-1)
Microsoft Excel 2000 (9.0.3821 SR-1)
The function is below.
Any suggestions on what may be interfering?
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Text0.SetFocus
myFileName = Text0.Text
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "Data"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Data", myFileName, True
mySQL = "DELETE Data.* FROM Data WHERE (((Data.ITEMNUM) Is Null))"
DoCmd.RunSQL mySQL
DoCmd.SetWarnings True
Form_ImportList.Visible = False
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
PB