I'm using the following code to import a Excel spreadsheet into a access Database:
Dim appAccess As Access.Application
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase "path_to_db"
appAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "my_db_table_name", "path_to_excel_file", hasFieldNames, acImportRange
The first Column in my Database is the Primary-Key. I don't get any errors, if data with the same Primary-Keys are inserted. I would like to get errors however. How can I force an error if duplicate rows are contained in the spreadsheet?
