Solved

Delete Table Module

Posted on 2006-07-20
4
385 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

932 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now