listbox filter

skate

Registered User.
Local time
Today, 11:33
Joined
May 22, 2002
Messages
136
I have a listbox that displays data according to a selection from a combobox. Now I want the user to be able to make a selection in the listbox and then a subform filters it's records accordingly. Suggestions? This is what i wrote, but it is obviously wrong.

Private Sub lstResults_Click()
On Error GoTo Err_Select_Click
Dim i As Integer
'12 months
i = 0
For i = 0 To 11
If lstResults.Selected(i) = True Then
Me.Day_subform.Form.Filter = "MIndex = lstResults.column(0)"
Me.FilterOn = True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70
End If
Next i
Err_Select_Click:
MsgBox Err.Number
Exit Sub
End Sub
 
One solution is to create a hidden field on your form to hold an index of the the value of the current record in the list box, then use that hidden field as criteria for your subform. Of course, requery your sufform after storing the hidden field.
 

Users who are viewing this thread

Back
Top Bottom