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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox filter...via a checkbox

Status
Not open for further replies.

NRK

Technical User
Feb 13, 2002
116
0
0
US
I have created a listbox that will filter a report based on its contents. There are times that I want to further filter the report by only allowing the report to show the listbox contents when their status = 'x'.

So, as an example, if there are 3 records in the listbox and I click 'cmdFilter', the report will show all three records. If I select a checkbox, then I would expect to see only two records (as they both have a status = 'x').

For some reason, this filter only works the first time. If I don't use the checkbox, the filter will work each time. If I want to use the checkbox, it will only work the first time.

I would appreciate any thoughts that you may have...I am stumped!
 
This is how I'm doing it (it may not be optimized, but it works):

Sub chkFilter_Click()
' Check for status of chkFilter
If (chkFilter.Value = True) then
Me!lstBox.RowSource = "SELECT Status,Field1 " & _
"FROM Table WHERE (Status = 'x')"
Else
Me!lstBox.RowSource = "SELECT Status,Field1 " & _
"FROM Table"
End If

' Refresh the listbox contents
Me!lstBox.Requery

End Sub

**Make sure the Requery command is there, that's what does the data refresh.
 
Gotcha! Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top