Syntax for IIF statement with checkbox

Eyor

Registered User.
Local time
Today, 13:22
Joined
Jul 13, 2006
Messages
26
I'd like to check if a field is a certain value then mark the checkbox but, I'm not sure of the syntax and am new to Acces and VB. Here's what I have so far:

IIf([SampleTypeCode]="Grab" Or [SampleTypeCode]="Integrated",[CheckGrab]=1)

I'm certain this syntax is incorrect but, unfortunately I don't have a refernece to check :o . What I'm trying to say in english terms is:

If the field [SampleTypeCode] contains the string "Grab" or "Integrated" then put a check in the checkbox.
 
Try:

IIf([SampleTypeCode]="Grab" Or [SampleTypeCode]="Integrated",[CheckGrab]=True)
 
Thanks for the response Paul.

That didn't generate any Syntax errors. The report ran mostly as expected but, all of the check boxes are empty, even the ones associated with [SampleTypeCode]="Grab" Or [SampleTypeCode]="Integrated" (I kept this field displayed on the report for now).

Not sure if this is due to the Syntax or my logic.
 
Thanks for the response Paul.

That didn't generate any Syntax errors. The report ran mostly as expected but, all of the check boxes are empty, even the ones associated with [SampleTypeCode]="Grab" Or [SampleTypeCode]="Integrated" (I kept this field displayed on the report for now).

Not sure if this is due to the Syntax or my logic.
 
I think I missed the forest for the trees. Where exactly is that formula?
 
The Formula is in a report which is generated from a cross-tab query. In the report I currently have all of the fields I need but, want to check if there exists a grab or integrated record without displaying the record, just display some mark that there is one.
 
Exactly where "in a report"? Control source of a control, code in an event, etc. I ask because there will be a different answer.
 
Ahh, sorry. It's in a Control Source.
 
As the control source of the checkbox, try:

=IIf([SampleTypeCode]="Grab" Or [SampleTypeCode]="Integrated",True,False)
 
Excellent!! Does just what it should. Many Thanks.
 
HTH. I should have noticed right away that your original post was sort of a mix of what you would do in code and what a formula would look like.
 

Users who are viewing this thread

Back
Top Bottom