Recordset Filters

S

SharonInGa

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
 
K

Ken Snell [MVP]

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
 

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