One of the easiest ways to deal with errors in a PowerApps form is to prevent them and stopping end-users from submitting incomplete forms is the quickest way to getting good data.
Disable Form Submit Buttons in One Step
The Error property of PowerApps forms contain a built-in not-so-friendly message that is invoked when form errors exist. This property is able to be exploited to disable submit buttons. I like to use the code in my Submit button’s DisplayMode property:
Feel free to enhance the button by changing the button’s fill color when it is disabled.
Invalid Field Data
Use Custom Errors to Direct Proper Input
Include custom errors to help combat human error in your PowerApps. In the following example, I make use of a custom error.
In the example, the second field’s value is dependent upon the first field’s value. If an inspector only inspected 6 unit sections in total, then it is impossible for the inspector to state that 7 sections were damaged. The maximum number of sections with damage could only be 6.
This error pops up immediately when an invalid value is entered. Here’s how I made it happen:
In the second field’s Error control within the text property, I used this code:
If('DamagedSections_DataCard2'.Update>'TotalSections_DataCard2'.Update,"The number of damaged sections may not exceed the number of sections inspected.")
Feel free to replace my data card names with your own.