List Box Refresh When Filtering (1 Viewer)

RodShinall

Registered User.
Local time
Yesterday, 20:36
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.
 

nIGHTmAYOR

Registered User.
Local time
Yesterday, 18:36
Joined
Sep 2, 2008
Messages
240
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
 

RodShinall

Registered User.
Local time
Yesterday, 20:36
Joined
Dec 21, 2006
Messages
32
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

Top Bottom