cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GBarron
Helper I
Helper I

Button Is Immune to Disabling (Magic?!)

Hey guys,

 

Sorry for the funny post title but serious issue:

I have a button that I want to disable based on some data in a form (fairly typical usecase I think- if fields are empty you can't submit). My problem is no matter what I do to this button, I can't get it to disable. It just... won't. I've had a variety of complex functions to check for various fields that I thought might be broken, but no.

 

I've boiled it all the way down to this. On the screen that the button is on I've set the OnVisible property to: Button3.DisplayMode.Disabled

 

And the button is still enabled. I've tried this same format in a dozen different places. It just... won't. I even put a button in that has that command. Nothing.

 

How is this not the right command and what am I doing wrong? I'm absolutely baffled here. The field just won't change.

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

To disable the button you need to put something in the DisplayMode property of the button.  For example, if you have a TextInput1 use the following formula in the DisplayMode of the button to disable it when TextBox1 is empty.

If(IsBlank(TextInput1.Text),DisplayMode.Disabled,DisplayMode.Edit)

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

4 REPLIES 4
Pstork1
Dual Super User III
Dual Super User III

To disable the button you need to put something in the DisplayMode property of the button.  For example, if you have a TextInput1 use the following formula in the DisplayMode of the button to disable it when TextBox1 is empty.

If(IsBlank(TextInput1.Text),DisplayMode.Disabled,DisplayMode.Edit)

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

C-Papa
Super User
Super User

Hi, you shouldn't refer to the button in your code. the below works by looking for changes in your form that is different to the data source

 

Set your button display mode to the below and change Form1 to your form name. 

If(Form1.Unsaved,DisplayMode.Edit,Disabled)

Thanks... Power Apps is very confusing to me coming from stuff like C#. I don't understand why I can't reference an object directly to adjust it's variables. Making a text box as a variable(!) is just baffling to me, but I appreciate the solution.

Pstork1
Dual Super User III
Dual Super User III

Its because C# is procedural and Power Apps is declarative.  You can't change the property of an object directly in code at runtime in Power Apps.  But you can change the value of a variable and have the property respond to that change.  For developers getting used to the non-procedural declarative form of the code is often a challenge.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,974)