auto deleting Sheet1$_ImportErrors

samonwalkabout

Registered User.
Local time
Today, 12:45
Joined
Mar 14, 2003
Messages
185
I have a wizard that allows users to easy import excel data into the database but on occation a bad record in the excel file will cause the database to create a Sheet1$_ImportErrors table with 1 record in it. Is there anyway to Delete these tables automatically?

Many thanks

Sam
 
Could you work something like the following in your code after the import:

DoCmd.DeleteObject acTable, "Sheet1$_ImportErrors"

???
kh
 
Would that code run if the table wasn't created?

Maybe i need to test for its existance frist then if true delete it.

Know how to check if an object exisits?
 
Not sure if it would error. Put the code in and test it without the table. If you get an error and it gives you an error number, trap it in the error routine and by pass the command. I'm sure there's a way to check for it's existance though. Just can't remember how right off the top of my head...

???
kh
 
Yep gives error object not found, will try and find the code for checking for objects in the forum.

Thanks for your help ken
 
Rough example - a better way would be to be to check if the table exists - this deletes it if it exists but does nothing otherwise

Code:
Public Sub DeleteErrorTable()
    On Error Goto Resume Next
    DoCmd.DoCmd.DeleteObject acTable, "Sheet1$_ImportErrors"
End Sub
 
Of course the DoCmd.DoCmd can also be written as:

DoDo.cmd

:D

kh
 
Thanks

Fitted it in to avoid any errors runs away fine. Always more than one way to skin a cat :D Thanks for the help
 

Users who are viewing this thread

Back
Top Bottom