How to determine whether a table exists in Microsoft Access using VBA, and there are two methods available.
发布时间
阅读量:
阅读量
方法一: 采用循环机制,验证目标表格是否存在于系统中
Function searchTable(TableName As String) As Boolean
searchTable = False '默认不存在
Dim tbl As DAO.TableDef
For Each tbl In CurrentDb.TableDefs
If tbl.Name = TableName Then
searchTable = True '如果存在,返回 Ture,并退出循环
Exit For
End If
Next
End Function
方法二: 判断表格是否存在可通过系统提供的错误提示信息进行识别
Function test()
MsgBox TableIsIn("测试表")
End Function
Function TableIsIn(TableName As String)
全部评论 (0)
还没有任何评论哟~
