Use ADO to check if Table exists

creeping

Registered User.
Local time
Today, 18:46
Joined
Feb 9, 2003
Messages
20
Does anyone know have to check in an access database if a table already exists with ADO?

Thanks
 
Access 2000:-
----------------------
Dim obj As Object

For Each obj In CurrentData.AllTables
If obj.Name = "TableName" Then
MsgBox "Table exists"
Exit For
End If
Next
-----------------------


The following ADO alternative requires making a reference to the Microsoft ADO Ext. 2.5 DDL and Security.
-----------------------
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table

cat.ActiveConnection = CurrentProject.Connection

For Each tbl In cat.Tables
If tbl.Name = "TableName" Then
MsgBox "Table exists"
Exit For
End If
Next
------------------------
 
Last edited:

Users who are viewing this thread

Back
Top Bottom