Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box Filter for a Form

Status
Not open for further replies.

cwassel

MIS
Oct 12, 2004
4
US
I have a combo box on a form that I want to apply a filter to my form. The combo box is populated with choices such as "Round 1", "Round 2", etc. "Round 1" and "Round 2" are the PeriodID for the records on the form. I want the user to be able to select the Round from the combo box and have the form filter to show only those records with a matching PeriodID. How would I write this code for the filter? Thanks for your time and help!
 
You should be able to use a wizard. If you have your form set up and you plop the combo down, let the wizard come up, and tell it that you want it to select records based on your choice. Then point it to the table and field.

misscrf

Management is doing things right, leadership is doing the right things
 
In the Open event of the form, populate your combobox using rowsource.

cboFilter.Rowsource="SELECT PeriodID FROM tbl GROUP BY PeriodID ORDER BY PeriodID"

To filter the form, something like...
Code:
If Not IsNull(cboFilter) Then
  Me.Filter = "PeriodID='" & cboFilter & "'"
  Me.FilterOn = True
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top