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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form problem...probably simple to fix

Status
Not open for further replies.

mrblonde

Technical User
Mar 16, 2001
187
US
I'm not sure how to get a filter to work on a form. I have a checkbox that I want to be the filter focus. (I'd like records that are checked to not show) I tried using the advanced filter, it asked me to save as a query...I just got confused from that point. Simple answer anyone?
 
create a command button on the form (cmdFilter), for it's caption use Apply Filter, for the On Click Event use this code, it requires a module level variable blnFilter


Dim blnFilter as Boolean


Private Sub cmdFilter_Click()
If blnfilter = False Then
blnfilter = True
cmdFilter.Caption = "Turn Filter Off"
Me.Filter = "[FieldNameGoesHere] = False"
Me.FilterOn = True
Me.Requery
Else
cmdFilter.Caption = "Apply Filter"
blnfilter = False
Me.FilterOn = False
Me.Requery
End If
End Sub
 
You can also place the same code behind your checkbox in the 'BeforeUpdate' event of that control, if you would rather not create another command button.

Gary
gwinn7
 
That code PaulF gave me works for turning the filter on, however clicking again on the button does not turn it off. See a problem?
 
Try setting the filter equal to nothing

Me.Filter = "" Mike Rohde
rohdem@marshallengines.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top