[求助]得到数据库中所有表的字段!
Sub TableInfo()
Dim i, j As Integer, Fname As String
Dim db1 As Database, Td1 As TableDefs
Dim fld1 As Fields
Dim FieldNum, RecNum As Integer
Fname$ = "d:\mdb\xx.mdb" ‘XX为ACCESS数据库文件
Set db1 = OpenDataBase(Fname$) '打开一数据库文件
Set Td1 = db1.TableDefs
For i = 1 To Td1.Count - 1
Debug.Print Td1(i).Name ‘输出表名
Set fld1 = Td1(i).Fields '出错!!!!
FieldNum = fld1.Count
RecNum = Td1(i).RecordCount
Debug.Print "当前表共有"; FieldNum; "个字段" ‘输出字段的个数
Debug.Print "当前表有:"; RecNum; "记录" ‘输出记录的个数
For j = 0 To fld1.Count - 1
Debug.Print "字段名", fld1(j).Name ‘输出字段名
Debug.Print "类型", fld1(j).Type ‘输出字段类型
Next j
Next i
End Sub
请高手指教一下