Need a piece of code that deletes a wildcard tbl after import & ap

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Because of permissions I need to delete the imported tables after they have
been appended.

I have tried various lines but because the filename can change i.e.
***_Filename, ***_Filename1 then this doesn't seem to remove them.

In the interim I am deleting manually.
 
Fishy,

This is not my code (THANKS to whoever wrote this!), wish I could remember
where I got it but anyway, it's what I use to get rid of imported error
tables. Perhaps you could modify this...

Public Sub DumpImportErrors()
Dim db As DAO.Database, tdf As DAO.Tabledef

Set db = CurrentDb

For Each tdf In db.TableDefs
If Right(tdf.Name, 11) = "ImportErrors" Then

db.TableDefs.Delete tdf.Name
End If
Next tdf

Set tdf = Nothing
Set db = Nothing
End Sub

Choose Compile from the Debug menu to make sure all is OK. If you get a
type not defined error, choose References from the Tools menu, scroll down
until you find Microsoft DAO 3.x Object Library and check it. After you get
it to compile, click the Save button and give your module a name. To run
this code, press CTRL+G to open the Immediate window, and type:

DumpImportErrors <<< Place this in the On_Open event of one of you forms OR
attach to a button. Just be sure they don't get deleted before you get a
chance to get the data out!

... and press Enter. Voila! Your tables should be gone.
--
Gina Whipp


"I feel I have been denied critical, need to know, information!" - Tremors
II
 
Back
Top