我需要使用VBA或Access SQL获取表的所有列名并迭代它们进行验证,有没有人有解决方案,我搜索谷歌无济于事。
答案 0 :(得分:16)
这将有效
Set db = CurrentDb()
Set rs1 = db.OpenRecordset("Table1")
Dim fld As DAO.Field
For Each fld In rs1.Fields
MsgBox (fld.Name)
Next
Set fld = Nothing
答案 1 :(得分:7)
Dim l As Integer
For l = 0 To CurrentDb.TableDefs("tbl_Name").Fields.Count - 1
Debug.Print CurrentDb.TableDefs("tbl_Name").Fields(l).name
Next l