Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the VBA function to determined if a table exist 2

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Access 2003

What is the VBA function to determined if a table
by the name of say "Table_Customer" exist.
 
This is from Microsoft:
Code:
Function TableExists(strTableName As String) As Boolean
    ' This procedure returns True or False depending on whether
    ' the table named in strTableName exists.
    Dim dbs As Database, tdf As TableDef

    On Error Resume Next
    Set dbs = CurrentDb
    Set tdf = dbs.TableDefs(strTableName)
    If Err = 3265 Then
        ' Table does not exist.
        TableExists = False
    Else
        ' Table exists.
        TableExists = True
    End If
    Err = 0
End Function
 
Here's a thread with even more options thread705-933401 ;-)

Roy-Vidar
 
... and just when you thought all options were exhausted,

(need refrence to "Microsoft ADO & DDL Security...")

Dim Cat New As ADOX.Catalog
Dim tbl As New ADOX.Table

Set cat.ActiveConnection = CurrentProject.Connection

For each tbl in cat.Tables
If tbl.Type = "TABLE" Then 'just for show
If tbl.name = strTable
TableExists = True
Exit For
End If
End If
Next

set cat = nothing




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top