以连续形式仅更改控制源选定的组合框 [英] Change control source only selected combo box in continous form
问题描述
正如您在此处看到的那样,用户可以选择合同或建议
As you can see here, the user can chose a contract or a proposal
如果参考提议或合同是参考控制源,则该参考源不相同.
The reference control source is not the same if it's a proposal or a contract.
所以在类型组合框类型更新后,我这样做
So in the after update of the type combo box type, I do this
Private Sub cbType_AfterUpdate()
If ([ReferenceType] = "Proposal") Then
cbReference.ControlSource = "[ProposalNo]"
cbReference.RowSource = "SELECT ProposalNo FROM Proposals WHERE ProposalNo is not null"
ElseIf ([ReferenceType] = "Contract") Then
cbReference.ControlSource = "[ContractNo]"
cbReference.RowSource = "SELECT ContractNo FROM Proposals WHERE ContractNo is not null"
End If
End Sub
问题在于它更改了所有行的控制源.
The problem is it change the control source for all rows.
是否有一种方法只能针对选定的行进行更改?
Is there a way to change it only for the selected row?
谢谢
推荐答案
不,没有.您可以将连续表单视为显示其他行的单个表单.对未绑定控件的任何操作都会影响所有行.有一些解决方法可能适合.例如,您可以显示参考的文本框和更改参考"组合.由于绑定的文本框不会更新,因此可以避免混淆用户.您可以使用条件格式设置更改组合的各种属性,以使其更加美观.另外,您可以使用两个子表单或弹出表单来编辑数据.
No, there is not. You can think of a continuous form as a single form that shows you other rows. Any action on an unbound control affects all the rows. There are work-arounds that may suit. For example, you can show a textbox for the Reference and a "Change reference" combo. This will avoid confusing users because the bound textbox will not update. You can set various properties of the change combo with conditional formatting to make it all prettier. Alternatively, you can use two subforms or a pop-up form to edit data.
这篇关于以连续形式仅更改控制源选定的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!