If, then, else

stuart_adair

Registered User.
Local time
Today, 13:21
Joined
Jan 13, 2009
Messages
57
Two questions in one night - I'm struggling today :p

I've got a form that opens to display records. Within the form is a field called c_exists that either contains the value Yes or No. I want a message to display on the screen that follows this basic logic...

iif([c_exists]="Yes","Complaint exists","No complaint registered")

I've tried putting an unbound field on the form and adding this to the query builder to run on load but it doesnt work.

Thanks

Stu:D
 
Why not put this into your query as a custom Expr?

Then you will get that in the correct place on your form?
 
Two questions in one night - I'm struggling today :p

I've got a form that opens to display records. Within the form is a field called c_exists that either contains the value Yes or No. I want a message to display on the screen that follows this basic logic...

iif([c_exists]="Yes","Complaint exists","No complaint registered")

I've tried putting an unbound field on the form and adding this to the query builder to run on load but it doesnt work.

Thanks

Stu:D

In order to use a Form Control in that manner, I believe that you will need to use the Full formal name of the control, which includes the name of the form, as opposed to just the name of the control.
 
iif([c_exists]="Yes","Complaint exists","No complaint registered")

If the control on the form is a Boolean Yes/No then the comparison should not be against a string as in 'Yes'. If you are using a string then you are using the wrong data type.

As a Boolean you can omit the comparison since the value is already true or false (Yes/No, On/Off etc are all the same). By including the comparison you are in effect saying:
IIf (True = True, etc

To refer to a control on a form you must include its full name.
Forms!formname!controlname

If you have another table storing the compalints then the storage of a field to indicate that a complaint exists is a normaization error. The control on the form should directly check the Complaints table for a related record.
 

Users who are viewing this thread

Back
Top Bottom