Change control source only selected combo box in continous form

邮差的信 提交于 2019-11-28 10:41:56

问题


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?

Thank you


回答1:


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.



来源:https://stackoverflow.com/questions/13019124/change-control-source-only-selected-combo-box-in-continous-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!