Full Version: Filtering with Combo Box?
UtterAccess Forums > Microsoft® Access > Access Forms
JMashburn
I've set up a Combo Box that gets its selection from a table with values I use to assign a record a "Level" or "Priority" type deal. It has Level 1 through Level 5 currently, but these levels can change their names or be removed or new ones added. It works fine, but now I'm trying to have another Combo Box that when the level is selected then the record set will be filtered by that level.
I'm not sure the best way to go about it. I've also got to keep in mind there should be a selection for not filtering or showing all records too in the Combo Box, but the Combo Box needs to also remain dynamic to whatever the levels are listed in the Rowsource of the level table.
Ideas?
Thanks for any Help.
CyberCow
In the AfterUpdate property of your UNBOUND combobox, you should be able to use the following VBA:
!--coloro:blue-->Forms![NameOfYourForm].FilterOn = True
Forms![NameOfYourForm].Filter = "[NameOfFieldAssociatedWithCombobox] = '" & Me.NameOfUnboundCombobox.Value & "'"

hope this helps
JMashburn
Thanks, I'll give that a try...
JMashburn
It worked with this:

Forms![Main].Filter = "[Level] = " & Me.Combo242.Value

In the VBA code... I still need an option to not filter or ShowAllRecords though.

The Rowsource for that combo looks like this:

SELECT [LevelTbl].[LevelNumber], [LevelTbl].[LevelName] FROM LevelTbl ORDER BY [LevelNumber];

Oalready have a macro with the ShowAllRecords action, should I just make a button for it and add code or an aditional action to clear the Combo242 field as well? Or, is there a simpler or more elegant way to include that as an option in the combobox selections?

Thanks for the help!


Edited by: JMashburn on Wed Sep 3 23:59:17 EDT 2008.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.