Is there a function in DAO 3.51 that checks whether a certain table name exist in a database (MDB) file without looping at each table?
Please help.
jade
Printable View
Is there a function in DAO 3.51 that checks whether a certain table name exist in a database (MDB) file without looping at each table?
Please help.
jade
You can use a sql statment and use one of the hidden tables in access (MSysObjects)
eg. "SELECT name FROM MSysObjects WHERE name = '" & your table & "'"
This will return any objects that are in your database.
Hope this helps
Ian
How about the TableDefs?
Code:Private Form_Load()
Dim z%
Dim MyDb As DAO.Database
Set MyDb = DBEngine.WorkSpace(0).OpenDatabase("<Your Database.",False,False)
'Set AllTableDefs to definitions of all tables in the database:
Set AllTableDefs = MyDb.TableDefs
"Check for Table
For z = 0 To AllTableDefs.Count - 1
If StrComp(AllTableDefs(z).Name,"<Your Table Name.",vbBinaryCompare) = 0 then
Msgbox "Table Found!",vbInformation + vbOkOnly
Exit Sub
Next
End Sub
Thanks Ianpbaker.
It worked. Again thanks a lot.