Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using wilcards to delete a table (Access 2000)

    This is part 2 of a question I asked yesterday...

    I use the code below to delete a table in my database when a user clicks a button. This works fine to delete the table called CenterChanges. The problem is I now have tables called CenterChanges20040406 and so on. Is there a way to add a wildcard character to strTableName to delete all tables which begin with CenterChanges*.*.. I know this might seem odd but it's just part of a bigger picture. Thanks for the help...


    Dim strTableName As String

    strTableName = "CenterChanges"

    Set db = CurrentDb

    db.TableDefs.Delete " & strTableName & "

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: using wilcards to delete a table (Access 2000)

    Something like:

    Dim db As DAO.Database
    Dim i As Long
    Dim n As Long

    Set db = CurrentDb
    n = db.TableDefs.Count

    For i = n To 1 Step -1
    If Left(db.TableDefs(i).Name, 13) = "CenterChanges" Then
    db.TableDefs.Delete db.TableDefs(i).Name
    End If
    Next i

    Set db = Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •