deleting a table if it exists

C

cb

Any help appreciated...

in my macro, which imports a text file each time it runs, I occasionally get an import errrors table generated, but not all the time... is there some way to put an action in the macro to delete a table, if it exists, that has the phase "import errors" in it...right now, I have to manually delete the import errors table every so often

thanks

Craig
 
J

Jim/Chris

I don't know how to do it in a macro but here is some
simple converrted macro code that you can put in your
On_Click event that
will delete the table. If the table does not exist it just
continiues on.

Private Sub Command12_Click()
On Error Resume Next
'*********
' Put your import commands here
'*********
DoCmd.DeleteObject acTable, "tablename1"
DoCmd.DeleteObject acTable, "tablename2"

Beep
MsgBox " tablename1 & tablename2 have been deleted"
'*********
' Or put your import commands here
'*********
delete_object_Exit:
Exit Sub

delete_object_Err:
MsgBox Error$
Resume delete_object_Exit

End Sub

Jim

-----Original Message-----
Any help appreciated...

in my macro, which imports a text file each time it runs,
I occasionally get an import errrors table generated, but
not all the time... is there some way to put an action in
the macro to delete a table, if it exists, that has the
phase "import errors" in it...right now, I have to manually
delete the import errors table every so often
 

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