Filter form with combo box drop downs

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

Guest

I have a continuous form based on a query(2 related tables). I would like to
have a couple of drop downs or text boxes that the users can use to filter
the form. The filters correspond to the query fields IndexField and Category.
They should be able to filter on one, both or none of the fields(display all
records). Can someone guide me through the process? Thanks.
 
Change the query the form is based on to include a WHERE statement like

WHERE (( IndexField Like [Forms]![frmYourForm]![cmb1]) AND ((Category Like
[Forms]![frmYourForm]![cmb2] )

In the combo boxes make the default "*" with limit to list no.

Then on your form create a command button that will check the two combo
boxes and requery the form like shown below.

If IsNull(Me.[cmb1]) = True Then Me.Cmb1 = "*" EndIF
If IsNull(Me.[cmb2]) = True Then Me.Cmb2 = "*" EndIF
Me.Requery
Me.Refresh

I use this in many screens to allow users to select any info they want.
 
Back
Top