Skip to main content

Notifications

Community site session details

Community site session details

Session Id : v3fJsW4IP2BrDFMbDzXjYB
Power Apps - Building Power Apps
Answered

Set checkbox value programatically

Like (2) ShareShare
ReportReport
Posted on 28 Jun 2021 16:54:28 by 24

The question I'd like to ask here is actually very simple.  So I'll put the question first and just in case the full context is underneath it.  Thanks!

 

THE QUESTION:

I want to set a checkbox value from the OnSelect of a button.  I thought I could do it by entering the following to the OnSelect formula of the button:

 

cbx_AssignedToMe.Value = false

 

Entering this formula does not result in any error.  But, alas, life is not this simple and when I press the button nothing happens.

 

I've searched around and this question always seems to get answered by explaining about the default value.  But I don't think that applies to my scenario.  I want to clear the checkbox programatically.  How can I do it?


THE CONTEXT:
I have built a filter screen with a bunch of different data filters that can be set.  On this screen are two checkboxes which act as simple helpers to set up two of the filters to the current user.  In the grab below, you can see that because I set the "Assigned to me" checkbox, the associated Assigned to: textbox got disabled and the user was automatically assigned to me.

bh4017_1-1624898760510.png

 

 

At the bottom of the screen I have a clear filters button which has the job of resetting all the filters.  As part of this, I want to clear the checkboxes back to false.


The filters themselves are easy to clear as I have them set up as variables and I can just use the Set(variable, value) method to do it.  This does result in all my filters being cleared.  But unfortunatley the checkboxes (if checked) stay checked and I need to clear them programatically.

 

 

Categories:
  • intherightplace Profile Picture
    30 on 04 Jul 2023 at 10:57:19
    Re: Set checkbox value programatically

    It's (more than) a little late now but this should work for setting off if it's on...

    If(cbx_AssignedToMe.Value, Select(cbx_AssignedToMe));

     

  • bh4017 Profile Picture
    24 on 29 Jun 2021 at 08:06:39
    Re: Set checkbox value programatically

    Thank you - I was able to adapt your solution to suit my scenario.  In my scenario I am only concerned with clearing the checkbox via a button, never checking them.  So the approach is different but the basis of your solution is sound and I've got it working.

     

    It does seem like a total 'round the houses' way to do something that I feel should be very simple.  I think I should be able to assign the checkbox value directly.

     

    But there you go, it is what it is and it's working - thanks again.

  • Verified answer
    TheRobRush Profile Picture
    11,121 Super User 2025 Season 1 on 28 Jun 2021 at 17:22:36
    Re: Set checkbox value programatically

    This is an example that will show you how to do this, not coded for your exact situation.

    In my example a single button sets both check and uncheck status, in yours you can split this between two buttons.

     

    Code for onselect of the button is.

    If(checkVar=true,
     Set(checkVar,false),
     Set(checkVar,true))

     

    Then you set the Default code of your checkbox to

     

    checkVar

     

    as checkVar is cycled between true and false by onselects the checkbox will check and uncheck itself

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

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,700 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard
Loading started