Form's control with iif statment to show specific records

Wysy

Registered User.
Local time
Today, 05:27
Joined
Jul 5, 2015
Messages
335
Hi,
I am having trouble with the following.
I have a form based on a query in datasheet view. What i would like is to show only those records that fulfill the truepart of iif statment, and do not show the ones that fulfill the false part.
I have the following fileds in the query
month
currency 1 checkbox
currency 2 checkbox
sum

In the form, the control named month contains the following code:
control source: =IIf([checkbox1]=no;[month];0)
So this gives the appropriate months, but also shows the all other records with a 0 in the month field. I would like to get only the records shown that are correct with the truepart of the statment.
thanks
Andrew
 
Andrew,

You should apply a filter to the query you are using for the form's record source, not to a field on the form. Open the form in Design View and open the Property Sheet, and then either edit directly the query and add a filter there or enter

[checkbox1] = True

in "Filter" box.

Shoji
 
thanks for the answer. The reason why i tried to filter data in the form is because i would like to use one query for different filtering purposes. I wonder if i can do it. However the query filtering works fine. Is there any other solution?
Andrew
 
No problems. You can set the filter at the form, keeping the query intact.

1. Open the property sheet of the form and choose "Data" tab.
2. At "Filter", enter
[checkbox 1]= True
3. Turn "Filter On Lord" to Yes.

That's all.
 
When using the forms Filter property, you need to use the name of of the field from the query not the name of a control.
 
Thank you, everything works fine now
Andy
 

Users who are viewing this thread

Back
Top Bottom