Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering using an option group

Status
Not open for further replies.

maxxev

Technical User
Jul 17, 2008
139
NL
Hi i'm trying to use an option group to filter a checkbox on a sub form... I'm not a programmer i'm just trying to muddle through.

I have option 1 set to TRUE, 2 to FALSE and these seem to work, but setting 3 to NULL is not working out for me, the checkbox is only a 2 perametre checkbox, but i'm trying to use the follwing code in the query for the checkbox records:

Forms![Form1]![ProjectStatus] WHERE (Forms![Form1]![ProjectStatus]) Is Not Null

Basically saying use the text box (ProjectStatus) unless the text box is null (the text box is recording the value from the option group).

It's probably just that I don't really know the SQL at all really, help appreciated.

Thank you.

 
Look up in Access Help the Triple State option on the property sheet of the checkbox, or option button.

This shows how you would use the TripleState property of the checkbox in a form. The checkbox can have 3 values rather than the common two.

A normal check box can have only values of 0 (unchecked) or -1 (checked) corresponding to Yes/No or True/False or On/Off

A triplestate checkbox can have the three values of True/Yes/On (-1), False/No/Off (0) and grayed out (Null state).


After a selection is made in the Check Activity check box, the user can then use the Run Query command to run a CASE statement.

The Case statement runs the query dependant on the value returned from the Check box.

In the Triple State property this can be either Yes(-1), No(0) or Null.

Private Sub cmdRunQuery_Click()
Select Case Me!chkActivity

Case Is = -1
' Filter for 'Active' returns -1
DoCmd.OpenQuery "qryFind_Active_Inactive"
Case Is = 0
' Filter for 'Inactive' returns 0
DoCmd.OpenQuery "qryFind_Active_Inactive"
Case Else
' Handle the instance where All values need to be returned
DoCmd.OpenQuery "qryFind_Active_Inactive"
End Select

End Sub
 
Hi, thank you for the response, however I don't want the check box to have 3 options, I just want to be able to filter the form to show, True, False and True&False together via the option group.

Cheers
 
Yes. I know. Did you see the last three words of my first sentence? The rest is an example showing exactly what you want to do. If it helps, change checkbox to option button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top