第1个回答 推荐于2016-09-28
Sub Show_AllTables() '表
On Error GoTo Error_Line
Dim rs As New ADODB.Recordset
Set rs = CurrentProject.Connection.OpenSchema(adSchemaTables)
With rs
Do Until .EOF
Debug.Print "Name=" & .Fields("TABLE_NAME") & "; Type=" & .Fields("TABLE_TYPE")
.MoveNext
Loop
End With
Exit_Line:
Set rs = Nothing
Exit Sub
Error_Line:
MsgBox Err.Description
Resume Exit_Line
End Sub
Sub Show_AllFields() '字段
On Error GoTo Error_Line
Dim rs As New ADODB.Recordset, myFieldName As ADODB.Field
Set rs = CurrentProject.Connection.OpenSchema(adSchemaColumns)
With rs
Do Until .EOF
Debug.Print "Table Name=" & .Fields("TABLE_NAME") & "; Field Name=" & .Fields("COLUMN_NAME")
.MoveNext
Loop
End With
Exit_Line:
Set rs = Nothing
Exit Sub
Error_Line:
MsgBox Err.Description
Resume Exit_Line
End Sub本回答被提问者采纳