I have a series of combo boxes that filter a dataset. In many cases having more than one of the combo boxes with a selection will yield no record matches. My thought is that when on of the combo boxes is selected the others could be reset. Problem is if each is looking at the other for a change the Reset is triggered for all of them.
Simple Example
ComboBox1 resets ComboBox2 if a selection is made in ComboBox1.
ComboBox2 resets ComboBox1 if a selection is made in ComboBox2 which triggers the OnChange of Combox1 which resets ComboBox2
How can I make this work? I think setting a variable might be the answer but not sure how to implement.
I think my issue was using OnChange and not OnSelect. If I update the variable OnChange then it creates a loop and resets the combo box I just changed. I updated the variable without setting it to Blank(). It works.
Reset is triggered on a change of variable from something that is not the trigger to a value that is. So before each reset, set it to Blank() or any other value.
UpdateContext({varReset: Blank()});
UpdateContext({varReset: Reset1})
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
@WarrenBelz
Thanks. I did find that issue and removed it. Looks like your solution works but I run into issues with the reset if I need to account for more than one control. For example, I tried something like this on the Reset of CoboBox1
Or(varReset = "Reset1", varReset = "Reset2")
and
varReset = "Reset1" || varReset = "Reset2"
Neither of these throw and error but neither work. I'm not exactly sure why. I've thrown a label into the app to make sure that the variable was being set with the OnChange event of each control.
Hi @futr_vision ,
The only reason you would get a compatibility error is if you are using varReset somewhere else with a different data type. You can call the Variable whatever you want, but the idea of Text variable is that you can change it to different values and when it is changed to the value that the particular control has as its Reset trigger, that control will reset. So OnChange of each control, you can set the Variable to the Reset trigger of the other.
Hi @WarrenBelz,
Am I setting that variable at the OnChange property of combo box 2?
varReset = "Reset1" also gives me an incompatibility error.
How would this work if I need to reset more than one control?
I was thinking that maybe when a value in a control is chose then I can set a variable to a representation of that control. For example if I was working with ComboBox1 then I would set a variable to "ComboBox1". If I made a selection in ComboBox2 then I would change that variable to "ComboBox2". Then there would be some logic on each control that would check that variable and if the value was anything other than the value of the control then the combo box would be set to blank. Does that make sense?
Hi @futr_vision ,
Make a text variable on box 2
UpdateContext({varReset: "Reset1"})
And the Reset property of box 1
varReset = "Reset1"
the do the opposite on the other one using “Reset2”
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
WarrenBelz
146,524
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,906
Most Valuable Professional