Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
646 views
in Technique[技术] by (71.8m points)

ms access - Change control source only selected combo box in continous form

As you can see here, the user can chose a contract or a proposal

enter image description here

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...