Visual Basic Coding for Msg Box (1 Viewer)

lucy1216

Registered User.
Local time
Yesterday, 21:50
Joined
Feb 28, 2013
Messages
11
What I am trying to do is display a message when a calculated field on the form is 0 and another message if it isn't.
I have a form that has a total for a table, an entry box to put in the total of an imported vendor spreadsheet and a calculated field to show the difference, if any.
I am lost as to how to write the code...
What I want to do if basically this:

IIf [Difference] = 0, "Balanced", "Out of Balance".

I have tried to put this statement into the validation rule on the "Difference" field; however, it is not working.

I would much rather get some direction as to how to write the code.

Thanks in advance and sorry for the rambling.
 

Beetle

Duly Registered Boozer
Local time
Yesterday, 22:50
Joined
Apr 30, 2011
Messages
1,808
You could do this in a calculated field in a query, or a calculated control (i.e. text box) on a form or report, assuming that the [Difference] field exists in the recordset, but the IIf function arguments must be enclosed in parantheses;

IIf([Difference]=0, "Balanced", "Out Of Balance")
 

lucy1216

Registered User.
Local time
Yesterday, 21:50
Joined
Feb 28, 2013
Messages
11
Okay, so where on the properties tab do I put the IIf statement?
 

Beetle

Duly Registered Boozer
Local time
Yesterday, 22:50
Joined
Apr 30, 2011
Messages
1,808
If your intent is to do this in a calculated text box on a form or report, then you put it in the Control Source of the text box, preceded by the = sign;

=IIf([Difference]=0, "Balanced", "Out Of Balance")
 

Users who are viewing this thread

Top Bottom