4 个解决方案
#2
Sub AllTables()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllTables collection.
For Each obj In dbs.AllTables
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub
#3
RunCommand 方法用于执行内置菜单命令或内置工具栏命令。
expression.RunCommand(Command)
expression 必需。返回“Applies To”列表中的一个对象的表达式。
Command AcCommand,必需。固有常量,指定要执行的内置菜单命令或内置工具栏命令。
AcCommand 可以是下列 AcCommand 常量之一:
acCmdDiagramNewTable
acCmdNewObjectTable
acCmdQueryTypeMakeTable
acCmdTableAddTable
#4
参数说明
Conn ADODB.connection
TableName 表名
返回值,存在返回True 不存在返回False
Conn ADODB.connection
TableName 表名
返回值,存在返回True 不存在返回False
Public Function TableExists(ByRef Conn As Object, ByVal TableName As String) As Boolean
Dim Rs As Object
TableExists = False
If Conn.State = 0 Then Exit Function
Set Rs = Conn.OpenSchema(adSchemaTables)
Do Until Rs.EOF
If Rs("TABLE_NAME") = TableName Then Exit Do
Rs.MoveNext
Loop
TableExists = Not Rs.EOF
Set Rs = Nothing
End Function
#1
#2
Sub AllTables()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentData
' Search for open AccessObject objects in AllTables collection.
For Each obj In dbs.AllTables
If obj.IsLoaded = True Then
' Print name of obj.
Debug.Print obj.Name
End If
Next obj
End Sub
#3
RunCommand 方法用于执行内置菜单命令或内置工具栏命令。
expression.RunCommand(Command)
expression 必需。返回“Applies To”列表中的一个对象的表达式。
Command AcCommand,必需。固有常量,指定要执行的内置菜单命令或内置工具栏命令。
AcCommand 可以是下列 AcCommand 常量之一:
acCmdDiagramNewTable
acCmdNewObjectTable
acCmdQueryTypeMakeTable
acCmdTableAddTable
#4
参数说明
Conn ADODB.connection
TableName 表名
返回值,存在返回True 不存在返回False
Conn ADODB.connection
TableName 表名
返回值,存在返回True 不存在返回False
Public Function TableExists(ByRef Conn As Object, ByVal TableName As String) As Boolean
Dim Rs As Object
TableExists = False
If Conn.State = 0 Then Exit Function
Set Rs = Conn.OpenSchema(adSchemaTables)
Do Until Rs.EOF
If Rs("TABLE_NAME") = TableName Then Exit Do
Rs.MoveNext
Loop
TableExists = Not Rs.EOF
Set Rs = Nothing
End Function