Control Source If statement

Ish picture Ish · Jun 5, 2012 · Viewed 12.4k times · Source

I want access to automatically calculate the output if the entered value is > 0. So I put the following code in the "Control Source" field of a textbox property and it is giving me an error. The Number should be obtained from Text052 and it should output it in Text054.

Here is the code:

If Text052.value > 0 then
Text054.value = Val([Text052].[Value])/2
end if

Error: "The expression you enetered contains invalid syntax". "You have enetered the operand without the operator"

I am not sure how to write the syntax in the control source field of the text box propety. Please advice.

Answer

Fionnuala picture Fionnuala · Jun 5, 2012

In the control source of Text054, try:

=IIf([Text052] > 0,[Text052]/2, "N/A")

"N/A" can be whatever you need, including null.