Import Error Table

gblack

Registered User.
Local time
Today, 14:44
Joined
Sep 18, 2002
Messages
632
I want to set up a way to automatically delete an import_error table, or make it so that access doesn't make one (ideal). Can I do this?

Gary
 
Gary,

I use the following code to delete import error tables.

Code:
Dim db As Database
Dim tdf As TableDef

Set db = CurrentDb

For Each tdf In db.TableDefs
If tdf.Name Like [COLOR=Red]"E*" [/COLOR] Then
DoCmd.DeleteObject acTable, tdf.Name
End If
Next
Set db = Nothing

Generally the import error tables in my projects are mainly due to type conversions. If I formatted the spreadsheets and ensured the data was in a correct format then access wouldn't generate these I suppose.

All of my import error tables generally begin E1**_Importerrors which is why in the code it looks for tables beginning with 'E' see the red highlight in the code.

Hope this helps

Andy
 
Thanks

That's what I was looking for.

LOL. Ya, so was the old post as well. I'll try looking for it first next time.

Gary
 
Or shorter way:

Dim tbl As TableDef

For Each tbl In CurrentDb.TableDefs
If tbl.Name Like "*" & "Error" Then CurrentDb.TableDefs.Delete tbl.Name
Next
CurrentDb.TableDefs.Refresh
 
Thanks!

Ya that is nice and compact and works fine, although I had to change the "E*" to "*Error"...but yep, that did the trick.

Thanks,
G
 

Users who are viewing this thread

Back
Top Bottom