How can I delete a table only if it exists? Or can I import the Excel files to replace the existing tables? XLSX files are always the same and table names are always the same.
Code works fine, but we are in area with lots of electrical outages and computer shut down while this was in process.. and table had already been deleted.
Following is the code I use to import the Excel XLSX. (If a table is already deleted, this crashes with message that the table does not exist)
Private Sub Command0_Click()
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "QB ITEM LIST"
DoCmd.DeleteObject acTable, "QB PENDING BUILDS"
DoCmd.DeleteObject acTable, "QB OPEN POs"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "QB ITEM LIST", "C:\Users\Jim\Desktop\QB Reports as XLSX\EXPORT TO MS ACCESS ITEM LISTING.xlsx", True, "Sheet1!"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "QB PENDING BUILDS", "C:\Users\Jim\Desktop\QB Reports as XLSX\Export to Access PENDING BUILDS.xlsx", True, "Sheet1!"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "QB OPEN POs", "C:\Users\Jim\Desktop\QB Reports as XLSX\Export to Access OPEN PURCHASES ORDERS.xlsx", True, "Sheet1!"
DoCmd.RunMacro "001 PROCESS DAILY OPEN POS PENDING BUILDS, ITEM LIST & INV"
DoCmd.SetWarnings True
MsgBox "THIS PROCESS IS FINISHED, YOU CAN RETURN TO MAIN MENU!"
DoCmd.OpenForm ("Switchboard")
End Sub
Thanks,
Jim