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

How do you create a button that will automatically filters a field

Status
Not open for further replies.

raggamuffin11

Technical User
Nov 12, 2001
1
US
I need help creating a button that will filter a field. I need to be able to type in the criteria into the field and then click on the button and it will filter the criteria that I just typed in. I'm not talking about auto populate.
 
Have a look at the topic "Filter By Form" in the Access Help File.

If this doesn't help, the second option is to base your form on a query, and pass the entered criteria to the query as needed.
 
Hi
i take it you want to apply the filter by clicking a button on a form i have used the following code attached to a form to filter the subform

Private Sub ShowReconciled_Click()
' Robert Dwyer 5-Dec-2000
On Error GoTo Err_ShowReconciled_Click
' Togle between Reconciled Only and All Records type display

If Me![BankReconSub].Form.FilterOn Then
' remove filter to show All records
' and change button caption
Me![BankReconSub].Form.FilterOn = False
ShowReconciled.Caption = "&Reconciled Only"

Else
' apply filter to show only reconciled records
' and change button caption
Me.BankReconSub.Form.Filter = "BankReconSrc.BankedDate Is Not Null"
Me![BankReconSub].Form.FilterOn = True
ShowReconciled.Caption = "All &Records"

End If

-------

to apply the filter to the main form you should only need to change the

Me.BankReconSub.Form.Filter =

to
Me.Form.Filter =

the filter equates to a where clause in SQL so you will need to adapt this to suit your needs. with some additional code you could offer a more choice and conditions but that is up to you. Changing the button caption allows you to indicate the status of the displayed data ie filtered and how &etc

regards


Robert Dwyer
rdwyer@orion-online.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top