PDA

Click to See Complete Forum and Search --> : How do I...?


jade
Jun 4th, 2000, 10:08 AM
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

Ianpbaker
Jun 4th, 2000, 08:12 PM
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

Chris
Jun 6th, 2000, 12:28 AM
How about the TableDefs?

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

jade
Jun 7th, 2000, 02:45 PM
Thanks Ianpbaker.

It worked. Again thanks a lot.