Recordset Filters

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Novice using VBA ... Strong in Access
The user needs to filter specific records by either quarters, Prod Type or
both quarter and prod type from a form. First, what type of object (command
button, drop down box, etc) should the user select to run the filter?
Second, I need an explanation and code sample of how to pass the user's
selection into the code.


Quarter ProdType

2004-01 Prod A
2004-01 Prod B
2004-04 Prod A
2004-07 Prod A
 
Use combo boxes for user to select the filtering criteria. Use a command
button to run the filter.

You "apply" the filter by putting criteria expressions in the query that is
the form's recordsource. For the field that applies a combo box's value, use
a criterion like this:
[Forms]![FormName]![ComboBoxName] Or [Forms]![FormName]![ComboBoxName]
Is Null

Be sure both sets of criteria (one for each field that is being filtered)
are on the same "line" of the QBE grid.

Then, in the command button on the form, the code is just to requery the
form's recordsource:

Private Sub CmdButtonName_Click()
Me.Requery
End Sub
 
Back
Top