Link to home
Start Free TrialLog in
Avatar of IsleOfView
IsleOfView

asked on

Simple If Formula Question

I have a form that has a set of fields, of type number, that need to be set to zero, if the user doesn't enter a number.  I just wanted to write a formula on QuerySave to accomplish this.  Here's what I did:

fldLocationIP1 = @If(fldLocationIP1 = ""; "0"; fldLocationIP1)

What might be wrong with this?
TIA!
Avatar of wrichard
wrichard

Try these simple changes...
fldLocationIP1 := @If(fldLocationIP1 = ""; 0; fldLocationIP1)

You could also place this formula in the default value so that each field is automatically set to 0
Avatar of IsleOfView

ASKER

When I put that into the QuerySave event, I get the following error (when attempting to save the formula):

No main or selection expression in formula "

Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of wrichard
wrichard

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for trying, but that didn't work either.

Here's what I finally got to work.  I placed the following code in the InputValidation event for each field I needed checked:

FIELD fldLocationIP1:=fldLocationIP1;
@If(fldLocationIP = ""; @Failure(@SetField("fldLocationIP1"; 0)); @Success)

That seems to do the trick!