Conditional delete object

C

ChrisR

I have a macro that runs an import of a text file. typically there are some
errors that create an error table. To keep from having them buildup I would
like to have a condition to delete object (the error table) before import so
that it removes the last error table. Has to be a condition because if I
don't have a condition and there is no error table, my macro errors out.
Any help would be greatly appreciated.

My only idea on my own is to convert the macro to a module and have it
resume next on error so that it just skips the delete object if the object
is not there.

c-
 
G

Guest

Chris

Try using this code:-

If IsNull(DLookup("[Name]", "MSysObjects", "[Name]= 'MyTable' And [Type] =
1")) = False Then
CurrentDb.Execute "drop table MyTable"
End If

Andy W
 
S

Steve Schapel

Chris,

Use the equivalent of this for the Condition of your DeleteObject macro
action...
DLookup("[AField]","YourTable")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top