Solved

Delete Table Module

Posted on 2006-07-20
4
388 Views
Last Modified: 2006-11-18
I'm running a module in access to delete a table each day but I have more than one table that needs to be deleted
the code is;

Public Function DeleteTable()
Dim tdf As TableDef
For Each tdf In CurrentDb.TableDefs
  If tdf.Name = "B0101" Then
    DoCmd.DeleteObject acTable, tdf.Name
    CurrentDb.TableDefs.Refresh
  End If
Next tdf
End Function

but I need to delete "B0101", "B0102", "B0103" etc....
can someone show me how to add the other tables into the code?
0
Comment
Question by:smidgen
  • 2
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 17150716
Hi smidgen,

Depends what 'etc' means.

If you just want to delete all tables beginning with B then :

if left(tdf.name,1) = "B" then


Pete
0
 
LVL 3

Expert Comment

by:JefKve
ID: 17150726
Public Function DeleteTable()
Dim tdf As TableDef
For Each tdf In CurrentDb.TableDefs
  If (tdf.Name = "B0101" or tdf.Name = "B0102" or tdf.Name = "B0103")  Then
    DoCmd.DeleteObject acTable, tdf.Name
    CurrentDb.TableDefs.Refresh
  End If
Next tdf
End Function

but I need to delete "B0101", "B0102", "B0103" etc....
can someone show me how to add the other tables into the code?
0
 

Author Comment

by:smidgen
ID: 17150753
thanks peter57r
worked perfectly
0
 
LVL 77

Expert Comment

by:peter57r
ID: 17150763
Thanks

Pete
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question