Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Does a table exist? (Win XP Office 2003)

    I want to know from VBA code if an unopened table exists in my db. Can you point me down the right road, please?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does a table exist? (Win XP Office 2003)

    Put the following code in a module (Don't name the module TableExist, but anything else)

    Function TableExist(Tablename As String)

    Dim tblName As TableDef
    For Each tblName In CurrentDb.TableDefs
    If tblName.Name = Tablename Then
    TableExist = "Yes"
    Exit Function
    End If
    Next
    TableExist = "No"

    End Function

    To use the function in your code use something like

    If TableExist("YourTableName") = "Yes" Then
    ... code to execute if the table exist
    End If
    Francois

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Does a table exist? (Win XP Office 2003)

    Just fine! Thanks.

Posting Permissions

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