我想在Access窗体中创建两个CombiField:
有什么想法吗?
(*)我已经有了第一个代码:
SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Flags)=0) AND ((MSysObjects.Type)=1));
答案 0 :(得分:3)
将组合框的 RowSource 属性设置为表的名称(= ComboBoxTable)。
然后将 RowSourceType 属性设置为:字段列表
Private Sub ComboBoxTable_AfterUpdate()
Me!ComboBoxFields.RowSource = Me!ComboBoxTable.Value
End Sub
答案 1 :(得分:0)
在第一个组合的AfterUpdate中尝试下面的代码
Private Sub Combo0_AfterUpdate()
Dim TableName As String
TableName = Me.Combo0.Value
Dim rs As New ADODB.Recordset
Set rs = CurrentProject.Connection.OpenSchema(adSchemaColumns, Array(Empty, Empty, TableName))
Dim fldname As String
rs.MoveFirst
Do Until rs.EOF
fldname = fldname & rs!Column_Name & ";"
rs.MoveNext
Loop
Me.Combo2.RowSource = fldname
Me.Combo2.RowSourceType = "Value List"
Me.Combo2.Requery
End Sub