The latest Access 2000 How To's article explains how to apply a filter to an Access 2000 form by using a combo box as a filter parameter.
This Access 2000 How To's article explains how to apply a filter to an Access 2000 form by using a combo box as a filter parameter. You can use the filter property to specify a subset of recordset to be displayed.
Create the People Table
- PeopleId, AutoNumber
- PeopleAffected, Text
Create the Process Table
- ProcessId, AutoNumber
- ProcessName, Text
Create the ProcessToPeople Table
- Id, Autonumber
- PeopleId, Number
- ProcessId, Number
Create a Query called qryPeopleAffected
- Join the Process table to the ProcessToPeople table on the ProcessId field.
- Join the People table to the ProcessToPeople table on the PeopleId field.
Create a Form called PeopleAffected
- Select the form wizard.
- Select the qryPeopleAffect query as the date source.
- Select all the fields.
- Select Columnar as the type of form.
- Title the form "People Affected".
- In the Form Header, drag and drop an unbound combo box and change the caption to "filter".
- Open the Properties dialog for the combo box. Name the combo box "cboSelectableProcess".
- Start the Query Builder (QB) from the "Record Source" item property.
- QB: Select the Processes table and drag and drop the ProcessId and ProcessName fields into the design grid. Click X to close the window and answer "yes" to updating the property with the SQL. Change column count property item to 2. This will allow you to see the processid and processname in the combo box.
- Launch the Code builder from "On Click" property item for the combo box. Choose the code builder option.
- Insert the following code fragment:
Private Sub cboSelectableProcess_Click()
If .ListIndex <> -1 Then
'sProcessId = .SelText
'Retrieves the value of the bound column which may more may not be
'displayed in the list box
Filter = "ProcessId=" & sProcessId
FilterOn = True
MsgBox "Filter Applied"
- Dataview: The final result is all records displayed during the initial load, and as the user selects a processid from the cboSelectableProcess combo box, the code parameterizes the filter's "Where" clause with the selected process id.
Back to Access 2000 How To's Series Home