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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find out if a Table Exists in Access 97

Status
Not open for further replies.

BruceMJC

IS-IT--Management
Jul 2, 2003
8
US
With the stupid help MS Access has, I can't find a function to tell me if a particular table exists in the database. I know what table name I'm looking for. Any help here?
 
Hi BruceMJC,

Paste this into a module:

Public Function booTableExists(strTableName As String) As Boolean
Dim dbs As Database, tdf As TableDef
booTableExists = False
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If tdf.Name = strTableName Then
booTableExists = True
End If
Next
Set dbs = Nothing
End Function

To use the above:

MsgBox booTableExists("Table1")

Obviously, edit the above to your own requirements. Returns True or False.

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top