Delete Object

John liem

Registered User.
Local time
Today, 21:52
Joined
Jul 15, 2002
Messages
112
I have sometimes ImportErrors during the import of Excel file to my Access table and using:
Domd.DeleteObject acTable, "File1$_ImportErrors" to delete the errors.
But if there is no error occured, I will get an error message saying that Access cannot find the Object ImportErrors and stop doing the rest of the process.
How can I program that if this ImportError is not found, it goes to the next command. Thanks
 
put:

On Error Resume Next

at the start of your sub/function

Personally, I'd make a function to determine if the table exists.

i.e.

Code:
Public Function DoesTableExist(ByVal strTable As String) As Boolean
    On Error GoTo Err_DoesTableExist
    Dim tdf As DAO.TableDef
    Set tdf = CurrentDb.TableDefs(strTable)
    DoesTableExist = True
Exit_DoesTableExist:
    Set tdf = Nothing
    Exit Function
Err_DoesTableExist:
    DoesTableExist = False
    Resume Exit_DoesTableExist
End Function

i.e.

Code:
If DoesTableExist("Import Errors") Then
    CurrentDb.TableDefs("Import Errors").Delete
End If
 
Last edited:
Hi SJ,

Thanks for the solution and other suggestion, looks very goods to me. Appreciate y0our help. J
 

Users who are viewing this thread

Back
Top Bottom