creating two criteria on a form

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

Guest

I have a form with a combo-box list, and a command button that opens a report
for the product entered in the combo-box. The combo-box serves as creiteria
for the report. I would like to have not only a product drop-down list, but
also a date drop-down list. With the two criteria, the report would then
show product information by date. Does anyone know how to make this happen?
 
The simplest approach would be to list dates in the drop-down per the dates
in the table. So the RowSource property of the combo-box would look like:

Select [TheDate] From [TheTable] Group By [TheDate]

This can be impractical if this is a large table.

Once you have your combo listing the dates that you want, then mod the code
that opens the report to be something like this:

Private Sub Command0_Click()

On Error GoTo ErrorHandler

DoCmd.OpenReport "TheReport", , , "[Product] = """ & cboProduct & """,
and [TheDate] = #" & cboTheDate & "#"

Cleanup:
Exit Sub

ErrorHandler:
MsgBox Err.Number & ", " & Err.Description

Resume Cleanup

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

Back
Top