AOB
Registered User.
- Local time
- Today, 19:40
- Joined
- Sep 26, 2012
- Messages
- 627
I have a form with a number of "cascading" comboboxes, each with simple Table/Query RowSources.
When the user selects an option from the dropdown of the first combobox, the second combobox is requeried and revealed, with options relevant to the first selection.
And so on down the list; each successive combobox selection cascades down to the comboboxes below it.
I want to add code to the event handlers of each combobox, such that if any combobox selection changes, it "nulls" all the dependent comboboxes below and requeries them. Effectively, resetting the form from that point downward.
But - if the selection doesn't actually change - i.e. if the user clicks the dropdown, views the list, but just re-selects the same item that was already selected - I don't want them to lose any of the subsequent selections they may have already made further down the cascade.
So - the obvious thing to me would be to add code to the
What's weird is - when the
I've tried the
(Have also tried using the
Pretty sure I'm doing something dumb here but can't for the life of me figure it out
When the user selects an option from the dropdown of the first combobox, the second combobox is requeried and revealed, with options relevant to the first selection.
And so on down the list; each successive combobox selection cascades down to the comboboxes below it.
I want to add code to the event handlers of each combobox, such that if any combobox selection changes, it "nulls" all the dependent comboboxes below and requeries them. Effectively, resetting the form from that point downward.
But - if the selection doesn't actually change - i.e. if the user clicks the dropdown, views the list, but just re-selects the same item that was already selected - I don't want them to lose any of the subsequent selections they may have already made further down the cascade.
So - the obvious thing to me would be to add code to the
BeforeUpdate
event handler for each combobox and compare the .OldValue
with the .Value
- if they're the same, do nothing (the selection hasn't actually changed) - if they're different, reset any of the dependent comboboxes as necessary. Something along the lines of :
Code:
Private Sub cboCombo1_BeforeUpdate(Cancel As Integer)
If Not Nz(Me.cboCombo1.OldValue,"") = Nz(Me.cboCombo1.Value,"") Then
Me.cboCombo2.Value = Null
Me.cboCombo2.Requery
Me.cboCombo3.Value = Null
Me.cboCombo3.Requery
End If
End Sub
What's weird is - when the
BeforeUpdate
event fires, the .OldValue
is already set to the (new) .Value
- I can't see what the previous selection actually was?I've tried the
Change
and Dirty
events as well, same behaviour. I can't seem to capture the previous selection in time to make a determination as to whether the dependent comboboxes should be reset or not?(Have also tried using the
Form_BeforeUpdate
event but that doesn't fire at all; form isn't bound to anything)Pretty sure I'm doing something dumb here but can't for the life of me figure it out

Last edited: