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

Determine if a table exists in a database 1

Status
Not open for further replies.

jdbogie

IS-IT--Management
Joined
Feb 17, 2002
Messages
4
Location
US
I need a method of determining if a table already exists in a database (so that I dont append information to an existing one, or un-intentionally overwrite an old one)

Any ideas?

 
Use the AllTables collection (A2K) or the Tables collection (A97) and see if there is an object named "{your-table-name-here}" in it...

Look up the COLLECTIONS methods for more help - shouldn't take more than about 4 lines of code to return a TRUE or FALSE answer.

Jim How many of you believe in telekinesis? Raise my hand...
Another free Access forum:
More Access stuff at
 
The following should do what you are looking for:

Dim db As Object
Dim item As AccessObject

Set db = Application.CurrentData

For Each item In db.AllTables
If item.Name = <tablenamestring> Then
tblExists = True
Exit Sub
Else
tblExists = False
End If
Next item
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top