if isnull(DLookup("name", "MSysObjects", "name='表名'"))) then
真就是无此表
不知道还有别的更简单的吗?[em02][em02][em02]作者: hi-wzj 时间: 2006-8-2 19:58
如果有同名的窗体,就必须加上ParentId=251658241 的判断.作者: wwwwa 时间: 2006-8-3 00:08
捕获错误方法也可以,ACCESS不是SQL SERVER。作者: fan0217 时间: 2006-8-3 02:15
Public Function IsExistTable(strTableName As String) As Boolean
'===============================================================================
'-函数名称: IsExistTable
'-功能描述: 检查表是否存在
'-输入参数说明: 参数1:strTableName As String 检查表的名称
'-返回参数说明: Boolean True表示存在 False 表示不存在
'-使用语法示例: IsExistTable("表1")
'-参考: ADO帮助
'-使用注意:
'-兼容性: 2000,XP,2003
'-作者: fan0217@163.com
'-更新日期: 2006-03-17
'===============================================================================
On Error GoTo Error_IsExistTable
Dim Cnxn As New ADODB.Connection
Dim rstSchema As New ADODB.Recordset
Dim strCnxn As String
Set Cnxn = CurrentProject.Connection
Set rstSchema = Cnxn.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
If rstSchema!TABLE_NAME = Trim(strTableName) Then
IsExistTable = True
End If
rstSchema.MoveNext
Loop
rstSchema.Close
Cnxn.Close
Set rstSchema = Nothing
Set Cnxn = Nothing
Exit Function
Error_IsExistTable:
IsExistTable = False
If Not rstSchema Is Nothing Then
If rstSchema.State = adStateOpen Then rstSchema.Close
End If
Set rstSchema = Nothing
If Not Cnxn Is Nothing Then
If Cnxn.State = adStateOpen Then Cnxn.Close
End If
Set Cnxn = Nothing
If Err <> 0 Then
MsgBox Err.Source & "-->" & Err.Description, , "Error_IsExistTable"
End If
End Function