Deleting Tables

  • Thread starter Thread starter Maracay
  • Start date Start date
M

Maracay

Hi guys,

I have a system that import different files to the data base, those are
temporary tables, I don’t need them after I used, I also have 3 tables that
are permanent, what I want is to delete all the tables except the 3 permanent
tables, the name of the permanent tables are tblTemplates, tblRegular and
tblTwo.

Thanks
 
Hi guys,

I have a system that import different files to the data base, those are
temporary tables, I don¢t need them after I used, I also have 3 tables that
are permanent, what I want is to delete all the tables except the 3 permanent
tables, the name of the permanent tables are tblTemplates, tblRegular and
tblTwo.

Thanks

Copy and Paste the below code into a module.
Then run the module.

Public Sub DeleteSomeTables()
Dim t As TableDef
For Each t In CurrentDb.TableDefs
If t.Name = "tblTemplates" Or t.Name = "tblRegular" Or t.Name =
"tblTwo" Then
Else
DoCmd.DeleteObject acTable, t.Name
End If
Next t

End Sub

All tables will be deleted EXCEPT for the 3 named above.
 
Do the files that you import always have the same definition (i.e., fields)?

If so, you could save yourself some work by having a table into which you
import the 'raw' data, and queries that parse that data into your three
'permanent' tables.

This way, you'd only need to empty out the temp table before re-loading.

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
 
Back
Top