I'm trying to determine my error in this coding. I am looking to check if a table exists, if it does, delete it and import a new table that has the same name as the one I checked for (in this case, check for CPPS, delete it if it exists and add a new table named CPPS from a form value using import specs).
It appears that the isobject is not working, because it tries to execute the code even if there is no CPPS table. It also appears to duplicate the imported table (i.e. if the CPPS table has 100 records, it creates a table with 200 records, each one duplicated once).
Here is the code:
On Error GoTo CPPSnxt
If IsObject(CurrentDb.TableDefs("CPPS")) = True Then
DoCmd.DeleteObject acTable, "CPPS"
End If
CPPSnxt:
DoCmd.TransferText acImportDelim, "CPPS SEPS", "CPPS", CPPStxt.Value
Resume Next
End If