List Box Refresh When Filtering

RodShinall

Registered User.
Local time
Today, 06:55
Joined
Dec 21, 2006
Messages
32
I have a form containing a wizard generated list box that displays the "Subject" field for all of the records in my database and allows me to select any record for display. When I use Filter by Form or Filter by Selection I want the list box to refresh and display only those records in the current filter set. How do I do this? Any help would be greatly appreciated. I am a beginner using AccessVBA and am using Access 2003. Thank You.
 
i'll try to assume u mean u have a table named :
Table1
also a field named :
Subject
and then a listbox named :
listbox1

i will niglect the rest of the odd setting and the reason for all of this , then the code goes (in "On Filter" property of a form add the following code) :

Code:
Form.Refresh ' Required to get Current Form Filter property to update its status if returned
If Nz(Form.Filter,"")<>"" Then
      Me![listbox1].RowSource = "Select [Subject] From Table1 Where " & Form.Filter & ";"
End If
 
Thank you, nIGHT mAYOR for your response to my post. You solution worked like a charm. My list box now displays only the records I am filtering for when I use Filter by Form and click Apply Filter.
 

Users who are viewing this thread

Back
Top Bottom