我创建了以下代码,我想在将来使用它来获取表中所有字段的列表:
Private Sub btnGetFields_Click()
Dim myDBS As Database
Dim fldLoop As Fields
Dim fld As Field
Dim relLoop As Relation
Dim tdfloop As TableDef
Set myDBS = CurrentDb
With myDBS
' Display the attributes of a TableDef object's
' fields.
Debug.Print "Attributes of fields in " & _
.TableDefs("ALT_IDENTIFIER").Name & " table:"
'Error occurs in line below
Set fldLoop = .TableDefs("ALT_IDENTIFIER").Fields
For Each fld In fldLoop
Debug.Print " " & fld.Name & " = " & _
fld.Attributes
Next fld
.Close
End With
End Sub
但是Type Mistmatch - Runtime Error 13
当我运行代码时,我得到了回报。
为什么?fldloop
是 Fields 对象 - 即字段对象的集合,对吗?这是 TableDefs.Fields 过程返回的内容,为什么我会收到此错误?
谢谢