Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Set Variable When Combo box item is deselected?

(0) ShareShare
ReportReport
Posted on by

I am able to change the visibility of forms by setting the variable of Visible to true when an item is selected with my combo box, but I want to set it back to false when I deselect the item (its a single select combo box). I have this in the OnChange property:

 

If(!IsBlank(ReturningVisitorsBox.SelectedItems), Set(aVis, true), Set(aVis, false))
 
It's not setting back to false with this, is there somewhere else I need to put this in?
  • PatrickMcLeanGL Profile Picture
    on at
    Re: Set Variable When Combo box item is deselected?

    Worked perfectly thank you!

  • Verified answer
    bengo83 Profile Picture
    159 on at
    Re: Set Variable When Combo box item is deselected?

    Hi PatrickMcLeanGL

     

    Here is the code to set the variable:

    Set(aVis,CountRows(ComboBox1.SelectedItems)>0)
    I hope it helps 🙂
     
    Best regards
    Beny
     
     
  • kelseytran Profile Picture
    292 on at
    Re: Set Variable When Combo box item is deselected?

    Hi @PatrickMcLeanGL ,

     

    That code looks correct for the OnChange property, but that will only fire when the selected item changes, not when the selection is cleared.  Try keeping your code on the OnChange property, but add this to the OnSelect property of the control that clears the selection to reset the visibility variable:

    OnSelect:
     Set(aVis, false);
     Reset(ReturningVisitorsBox)

    ------------------------------------------------------------------------------------------------------------------------------
    If I answered your question, please accept my post as a solution and if you liked my response, please give it a thumbs up.

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,609 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,946 Most Valuable Professional

Leaderboard