I would like to use SetFocus on a control that isn’t filled out (i.e. Text Input) in my form when the submit button is clicked. The simplest way is to manually check all the controls and focus on the first one that isn’t filled out.
If(IsBlank(TextInput1.Text), SetFocus(TextInput1));
If(IsBlank(TextInput2.Text), SetFocus(TextInput2));
...
Here’s the kicker though, there are 144 possible fields to be inputted. This would be extremely tedious to grab the names of each control and check every single field manually, which is why I’m trying to avoid doing it this way.
The following is what I’ve looked into.
Is there any way to accomplish what I want to do, without checking every single field manually?
Unfortunately there is no way to do that in a simpler way today. In theory we could have something like the following:
With(
{ firstEmpty:LookUp([TextInput1, TextInput2, TextInput3, ...], IsBlank(Value.Text)) },
If(Not IsBlank(firstEmpty), SetFocus(Value))
)
But there are a few problems with it:
In this case I think the best option is what you have. You can also create a feature request (to access children of a form, and make the SetFocus work on this scenario) in https://aka.ms/powerapps-ideas