用ADO取出所有表的表名及字段名Public Function ListUserTable()
Dim rstSchema As ADODB.Recordset
Dim cnn2 As ADODB.Connection
Set cnn2 = CurrentProject.Connection
Set rstSchema = cnn2.OpenSchema(adSchemaTables)
Dim I As Long
Do Until rstSchema.EOF
If rstSchema("TABLE_TYPE") = "TABLE" Then
'对应 TABLE_TYPE 可以取值 "TABLE" "SYSTEM TABLE" "ACCESS TABLE"
'在这里我们列出所有用户表的信息,系统表不列出
For I = 0 To rstSchema.Fields.Count - 1
Debug.Print rstSchema(I).Name & "-> " & rstSchema.Fields(I).Value
Next
End If
rstSchema.MoveNext
Loop
rstSchema.Close
cnn2.Close
End Function