列表框显示列表名称
问题描述:
我试图获得一个列表框来显示特定表格中所有列(字段)的列表。现在下面的代码实现了这一点,但使用msgbox来显示我不想要的每个字段。列表框显示列表名称
Dim rst As DAO.Recordset
Dim fld As DAO.Field
Set rst = CurrentDb.OpenRecordset("YourTableName")
For Each fld In rst.Fields
MsgBox fld.Name
Next fld
rst.Close
Set rst = Nothing
Set fld = Nothing
基本上我想要一个组合或列表框来显示特定表中的所有字段 - 这可能吗?
答
你让自己太难了。
在列表框的属性窗格中,设置:
RowSource: YourTableName
RowSourceType: Field List
哦,我的天!我怎么没有看到这个!谢谢!咖啡因还没有踢进去! – itguyme