DOcmd.runSQL "Alter table" Syntax error (missing operator)in query expression

Ok this is what I have. I am trying to delete the ISRt table, import a spreadsheet and create a new ISRt, then add a autonumber column to the ISRt. I think I am on the right track.

Sub ISRimport()
DoCmd.RunSQL "DELETE TABLE ISRt"

Dim strFilename As String
strFilename = Environ("USERPROFILE") & "\DESKTOP\ISR.xls"
DoCmd.TransferSpreadsheet _
TransferType:=acImport, _
SpreadsheetType:=acSpreadsheetTypeExce97, _
TableName:="ISRt", _
FileName:=strFilename, _
HasFieldNames:=True, _
Range:="InventoryStatusReport_xls!A3:P$"

DoCmd.RunSQL "ALTER TABLE ISRt ADD REC_KEY COUNTER CONSTRAINT primaryKEY PRIMARY KEY"

End Sub

 

Question Info


Last updated February 11, 2018 Views 791 Applies to:
Answer
Answer

It's been ages since I used TransferSpreadsheet, but it seems there is no SpreadsheetType of acSpreadsheetTypeExce97.  Maybe you meant to useacSpreadsheetTypeExcel8

Make sure you tested Environ("USERPROFILE") & "\DESKTOP\ISR.xls" to check that you are constructing the correct path.

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.