表或查询是否存在 在 VB5 中需要 Microsoft DAO 3.x Object Library。 Public Const NameNotInCollection = 3265 Dim DB As Database Private Function ExistsTableQuery(TName As String) As Boolean Dim Test As String On Error Resume Next ' 该名字在表名中是否存在。 Test = db.TableDefs(TName).Name If Err <> NameNotInCollection Then ExistsTableQuery = True ' Reset the error variable: Err = 0 ' 该名字在查询中是否存在。 Test = db.QueryDefs(TName$).Name If Err <> NameNotInCollection Then ExistsTableQuery = True End If End If End Function