Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Sep 2006
    Posts
    166
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete tables with endings (Access 2000)

    I have a goof function deleting tables with ending 1. Can you help me rearrange the function so tas to delete the tables with endings 2 or 3 ?
    Function DeleteTablesEnding1()
    Dim dbs As DAO.Database
    Dim i As Integer
    Set dbs = CurrentDb
    ' Loop backwards through tabledefs
    For i = dbs.TableDefs.Count - 1 To 0 Step -1
    If Right(dbs.TableDefs(i).Name, 1) = "1" Then
    dbs.TableDefs.Delete dbs.TableDefs(i).Name
    End If
    Next i
    Set dbs = Nothing
    End Function

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

    Re: Delete tables with endings (Access 2000)

    Change

    If Right(dbs.TableDefs(i).Name, 1) = "1" Then

    to

    If Right(dbs.TableDefs(i).Name, 1) = "2" Or Right(dbs.TableDefs(i).Name, 1) = "3" Then

  3. #3
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Delete tables with endings (Access 2000)

    You could also use either of these methods

    Select Case Right(dbs.TableDefs(i).Name, 1)
    Case "1","2","3","4","5","6","7","8","9"
    etc............................
    End Select

    OR


    If Right(dbs.TableDefs(i).Name, 1) >= "1" And Right(dbs.TableDefs(i).Name, 1) <="9" Then
    Andrew

Posting Permissions

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