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

Trying to separate two functions in a button, help!

I'm building an app and I want to block the submit button when you select site/meeting or leave if none of the other fields are filled in. This works. However when I try to add in that I want "Lunch" and "Home" to display the submit button regardless, it won't work:

If(Dropdown1.Selected.Reason="Site/Meeting"||Dropdown1.Selected.Reason="Leave"||IsBlank(TextInput1)||IsBlank(DatePicker1.SelectedDate)||HourDropdown.Selected.Value="00"||MinuteDropdown.Selected.Value=":00",Disabled); If(Dropdown1.Selected.Reason = "Lunch"&& "Home", DisplayMode.View)

 

Please help

3 REPLIES 3
Super User
Super User

Re: Trying to separate two functions in a button, help!

@Alexyoung 

I have a few suggestions

 

First, please consider the arguments used within an IF statement.

If(Condition1,CodeWhenTrue1[,Condition2,CodeWhenTrue2]);

 

Some improvements I would suggest are:

  • Combine both IF statements
  • Use an OR condition for Lunch and Home

 

Put this code in the DisplayMode property of your button.

If(
    Dropdown1.Selected.Reason = "Lunch" || Dropdown1.Selected.Reason = "Home",
    DisplayMode.View
    Dropdown1.Selected.Reason="Site/Meeting"
    ||Dropdown1.Selected.Reason="Leave"
    ||IsBlank(TextInput1)
    ||IsBlank(DatePicker1.SelectedDate)
    ||HourDropdown.Selected.Value="00"
    ||MinuteDropdown.Selected.Value=":00",
    DisplayMode.Disabled
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Alexyoung Helper I
Helper I

Re: Trying to separate two functions in a button, help!

Hi,

Thanks for your help, but it doesn't work. 

There's no punctuation in the third line so it just comes back with an error and won't accept any separators I've tried to use.

Super User
Super User

Re: Trying to separate two functions in a button, help!

@Alexyoung 

Yes, I did miss a comma on Line 3.  Please put it in there.

 

If this doesn't work send a screenshot with the formula bar and error showing.  Sometimes you can't directly copy paste from this forum because it screws up the double quotes.  You might need to replace those.

If(
    Dropdown1.Selected.Reason = "Lunch" || Dropdown1.Selected.Reason = "Home",
    DisplayMode.View,
    Dropdown1.Selected.Reason="Site/Meeting"
    ||Dropdown1.Selected.Reason="Leave"
    ||IsBlank(TextInput1)
    ||IsBlank(DatePicker1.SelectedDate)
    ||HourDropdown.Selected.Value="00"
    ||MinuteDropdown.Selected.Value=":00",
    DisplayMode.Disabled
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (8,047)