|
|
Title | See if a table exists in a DAO database by using an On Error statement |
Description | This example shows how to see if a table exists in a DAO database by using an On Error statement in Visual Basic 6. |
Keywords | DAO, database, table, table exists |
Categories | Database |
|
|
Thanks to Simon.
The TableExists function tries to access a TableDef object with the indicated name in the TableDefs collection. If the table does not exist, then an error occurs and Err.Number is not 0.
|
|
Private Function TableExists(ByVal db As DAO.Database, _
ByVal table_name As String) As Boolean
Dim td As DAO.TableDef
On Error Resume Next
Set td = db.TableDefs(table_name)
TableExists = (Err.Number = 0)
End Function
|
|
|
|
|
|