web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If statment on a Button?
Power Apps
Answered

If statment on a Button?

(0) ShareShare
ReportReport
Posted on by 150

Hey everyone,

 

I'm wondering if this is possible.

 

I have 4 text boxes on an Edit Form:

Qty on Work Order

Total Qty

Qty Passed

Qty Failed

 

Qty on Work Order is tied to my ERP system

Total Qty is a calculated field summing Qty Passed and Qty Failed

Qty Passed is user input

Qty Failed is user input

 

I want to do an If statement on the "Submit" button that I have that submits the form. 

 

What I want to do is If Total Qty > Qty on Work Order, do not let the person submit the form and then display an error message.

 

Can this be done?? If so, what would the syntax look like?

 

Let me know if other information is needed.\

 

Thanks!

Categories:
  • cwebb365 Profile Picture
    3,334 Most Valuable Professional on at
    Sure, on the button depending on the value of your data. I would read straight from the datasource incase the qty changes instead of your form field, but something like

    If( whatever_populates_the_Total Qty > Whatever_populates_ Qty, SubmitForm(), Set(varError,"Your asking for more Qty than we have of " & whatever_populates_Total Qty)

    Then, you would put a label where you want the error and set it's Text property to varError. Then for visible on this label would be isBlank(varError) || isEmpty(varError)

    This will submit the form if your condition is met or else show that error and display it.

    You could put a Blank(varError); in front of the onselect if you wanted to reset it when clicking the button, or you can blank it out in another area when chaning Qty if you want to put a check in the onChange for that control.

    Hope this helps.
  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Danny_L ,

    Do you want to justify whether to submit the form based on data in that form?

    Do you mean that :
    1)Qty on Work Order, Qty Passed, Qty Failed are textinputs that you need to fill in data in the form?

    2)Total Qty is one calculated field=Qty Passed+Qty Failed 

    So you need to compare data in textinputs for Qty on Work Order, Qty Passed, Qty Failed?

    If so, please set the button's OnSelect like this:

    If(Value(QtyPassedtextinput.Text)+ Value(QtyFailedtextinput.Text)>
     Value(QtyonWorkOrdertextinput.Text),
    Notify("please do not make Total Qty larger then Qty on Work Order!",NotificationType.Warning),
    SubmitForm(formname)
    )

    //please replace with the textinput names.

     

     

    Best regards,

  • Danny_L Profile Picture
    150 on at

    That did it!!

     

    Thank you 😀

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard