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

Have filter on list box's record source?

Status
Not open for further replies.

lorirobn

MIS
Joined
Mar 15, 2005
Messages
450
Location
US
Hi,

I have a list box on a form. I needed to filter records displayed on the list box depending on a separate combo box selection. I coded the SQL and filter in the VBA module of the form, and it works fine. As I become more familiar with Access and VBA, I am wondering if there was a simpler way to do this, using a query as the list box's record source (which I can do easily), and adding a dynamic filter onto that.

Is there a way to add a filter onto the recordsource query of a list box, as you can do with a form's filter? It seems so complicated to have all that code within VBA (I am concerned about upkeep by users).

Thanks in advance...
 
Something like this?
faq702-4289
 
Hi MajP,

I think I wasn't clear about my question. My question is, is there a way to add a filter to the list box's query. I shouldn't have even mentioned the combo box at all.

My list box has a query as its record source. I may or may not want to filter records. I would dynamically like to add a filter, if so desired. I know this is possible with the form's record source (me.filter); it it also possible with a list box's record source?

Thanks...
 
I believe "filters" are inherant to FORMS. Seeing how your list box's record source is a query/sql, probably the best you could do is limit the data through a parameter or sort it.

 
lorirobn . . .

You can use an [blue]base SQL statement[/blue] to which you [blue]add dynamic criteria[/blue], updating the RowSource with the new SQL . . .

Your thoughts?

Calvin.gif
See Ya! . . . . . .
 
thanks... I guess I'll stick with what I have, which is exactly what Aceman suggests - a base SQL statement to which I dynamically add criteria.
Thanks...now I know I can't do a filter with my list box.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top