Change query criteria from a button

Keith Nichols

Registered User.
Local time
Today, 17:38
Joined
Jan 27, 2006
Messages
431
Hi,

The query for my form has a boolean field with ' like "No" ' in the criteria. I want users to be able to use a command button to change this to ' like "Yes" ' then requery the form.

Basically, what I want to do is toggle between current records ("No" in the boolean) and Archived Records ("Yes" in the boolean).

Any ideas?

Regards,
 
Do you mean toggle displayed data in form? If it is yes, then place checkbox YourCheckBox1 to form and use this code in OnClick event:

Private Sub YourCheckBox1_Click()

Me.Filter = "your_yesno_field = " & Me.YourCheckBox1
If Not Me.FilterOn Then Me.FilterOn = True

End Sub
 
Magic

Studentos said:
Do you mean toggle displayed data in form?

Studentos,

Yes, that's exactly what I meant.

Thanks for the code, I'll crank that into my form at the beginning of next week. Once I get that working I'm sure I can adapt it to use a button rather than a check box.

Just for background, I created a pseudo button & code to toggle the records displayed on the form between "active" and "current" projects. I did this rather than using a toggle command so that I could format the the 'button' depending on what records were showing. I intend to work this "show archived records" into the toggling action of my button.


I'll post back the results in a few days.

Edit: I dsolved the problem by removing the criteria from the form's underlying query and then filtered on the check box. Your post pointed me in a different direction which was very helpful. Thanks.

Solution posted on:
http://www.access-programmers.co.uk/forums/showthread.php?p=503931#post503931
Regards,
 
Last edited:

Users who are viewing this thread

Back
Top Bottom