A Functional Filter Button and Input Box for Access 2003/2000/2002

  • Thread starter Jarrod Shumaker
  • Start date
J

Jarrod Shumaker

The following will let the user input a value into a text box and filter on
a set of queries depending on what the submit to the function.
***************************

Button the user clicks
**************************

Private Sub Command429_Click()

DoCmd.ShowAllRecords
Me.FilterOn = False

If IsNull(Me![NAME OF INPUT BOX ON THE FORM]) Then

DoCmd.ApplyFilter "QUERY TO APPLY FILTER TO", ""
FilterOn = True

Else

DoCmd.ApplyFilter "QUERY TO APPLY FILTER TO", ""
FilterOn = True

End If

End Sub

***************************************************************************

Input Box
***************************************************************************

Private Sub FilterCase_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)

DoCmd.ShowAllRecords
Me.FilterOn = False
NAME OF INPUT BOX ON THE FORM = Null
NAME OF INPUT BOX ON THE FORM.SetFocus

End Sub
 
D

Douglas J. Steele

Command429_Click does the same whether the input box is Null or Not Null.

And is FilterCase intended to be NAME OF INPUT BOX ON THE FORM?
 
J

Jarrod Shumaker

Sorry Doug, i replied via e-mail

Just a quick note, this form is designed for an abstractor who wants to
check there work after inputting records at the end of the day.

********************************

Command429_Click has an If statement to apply 1 of 2 queries (notice the IF
statement is applied to [NAME OF INPUT BOX ON THE FORM], or FilterCase.
(That could answer both of your questions)

The query itself determines what is in the filter, so for instance, I have a
query designed to show null values is certain fields.

When the user leaves [FilterCase] Null it displays (filtered) the results of
the above query. (for instance, a null, ID/Case/Name

If the user inputs a case number that matches a case number in the database
it will filter on that one case number.

As for your second question, yes, FilterCase is intended to be "NAME OF
INPUT BOX ON THE FORM"

Sorry for my...less than conventional layout, I was in a hurry.

Here is the real code:

**********************************
Command Button

Private Sub Command429_Click()

DoCmd.ShowAllRecords
Me.FilterOn = False

If IsNull(Me![FilterCase]) Then

DoCmd.ApplyFilter "ReportHorryCheckingTMS", ""
FilterOn = True

Else

DoCmd.ApplyFilter "FilterCaseNumHorry", ""
FilterOn = True

End If

End Sub

*******************************************************
Input Box

Private Sub FilterCase_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)

DoCmd.ShowAllRecords
Me.FilterOn = False
FilterCase = Null
FilterCase.SetFocus

End Sub

Douglas J. Steele said:
Command429_Click does the same whether the input box is Null or Not Null.

And is FilterCase intended to be NAME OF INPUT BOX ON THE FORM?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jarrod Shumaker said:
The following will let the user input a value into a text box and filter
on a set of queries depending on what the submit to the function.
***************************

Button the user clicks
**************************

Private Sub Command429_Click()

DoCmd.ShowAllRecords
Me.FilterOn = False

If IsNull(Me![NAME OF INPUT BOX ON THE FORM]) Then

DoCmd.ApplyFilter "QUERY TO APPLY FILTER TO", ""
FilterOn = True

Else

DoCmd.ApplyFilter "QUERY TO APPLY FILTER TO", ""
FilterOn = True

End If

End Sub

***************************************************************************

Input Box
***************************************************************************

Private Sub FilterCase_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)

DoCmd.ShowAllRecords
Me.FilterOn = False
NAME OF INPUT BOX ON THE FORM = Null
NAME OF INPUT BOX ON THE FORM.SetFocus

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top