Solved

Delete Table Module

Posted on 2006-07-20
4
389 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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