Article ID: 129927
Article Last Modified on 7/1/2004
Public Const NameNotInCollection = 3265
Dim DB As Database
Private Function ExistsTableQuery(TName As String) As Boolean
Dim Test As String
On Error Resume Next
' See if the name is in the Tables collection:
Test = db.TableDefs(TName).Name
If Err = 0 Then
ExistsTableQuery = True
Else
' Reset the error variable:
Err = 0
' See if the name is in the Queries collection:
Test = db.QueryDefs(TName).Name
If Err = 0 Then
ExistsTableQuery = True
End If
End If
End Function
Private Sub Form_Load ()
Set DB = DBEngine.Workspaces(0).Opendatabase("Biblio.mdb")
Debug.Print "BadTable " ;IIF (ExistsTableQuery("BadTableName"), _
"does", "doesn't"); " exist."
Debug.Print "Authors " ;IIF (ExistsTableQuery("Authors"), _
"does", "doesn't"); " exist."
End Sub
BadTable doesn't exist.
Authors does exist.
Additional query words: kbHowTo kbVBp400 kbVBp500 kbVBp600 kbdse kbDSupport kbVBp
Keywords: kbhowto KB129927