Disabling a field after selecting checkbox in power apps

Photo by Andrew Neel on Unsplash

Disabling a field after selecting checkbox in power apps

To disable a field after selecting a checkbox in Power Apps, you can use the "OnChange" property of the checkbox control.

Here's an example:

  1. Add a checkbox control to your form, and name it "Checkbox1".

  2. Add the field that you want to disable, and name it "Field1".

  3. Select the "Checkbox1" control, and go to the "Advanced" tab in the right-hand pane.

  4. Click on the "OnChange" property, and select "Edit".

  5. In the formula bar, type the following formula:

    If(Checkbox1.Value=true, Set(DisableField1, true), Set(DisableField1, false))

    This formula checks whether the checkbox is selected. If it is, it sets a variable called "DisableField1" to true. Otherwise, it sets the variable to false.

  6. Select the "Field1" control, and go to the "Advanced" tab.

  7. Click on the "DisplayMode" property, and select "Edit".

  8. In the formula bar, type the following formula:

    If(DisableField1=true, DisplayMode.Disabled, DisplayMode.Edit)

    This formula checks the value of the "DisableField1" variable. If it is true, it sets the display mode of the "Field1" control to "Disabled". Otherwise, it sets the display mode to "Edit".

Now, when the user selects the checkbox, the "Field1" control will be disabled.