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!

Form filters replacing each other

Status
Not open for further replies.

krets

Technical User
Dec 29, 2006
214
0
0
US
I built a form with combo boxes that will be used to filter data in a subform. The main form is unbound and the combo boxes use select statements to pull values from the appropriate tables. Each combo box has an afterupdate event like:
Code:
Me![frmTechAIT].Form.Filter = "((Location = " & Chr(34) & Me.Location & Chr(34) & "))"
Me![frmTechAIT].Form.FilterOn = True

This form works as I want it to. You can select values in multiple combo boxes and it allows the user to build their filter slowly.

However, when I went to make another form and created in the same way it doesn't work the same. When I select values in a combo box it replaces the old filter instead of adding to it. I've been looking through my properties trying to figure out if something is different but I can't seem to find what it is.
 
Maybe you need to have a String Variable, and when you need to add to the filter, you can concatenate that variable, and use the variable instead of typing some of the details of the filter? I've not done much with filters to date, so I am not sure if that is even possible, but that'd be my first stab at it.

The Variable I'm talking of would be a Public variable, not a local procedural variable.

So, it would go here:
Code:
Option Explicit
Option Compare Database
[highlight]Public strMyVariable As String[/highlight]
---------

Private Sub Proc1()

   ~stuff here...

End Sub

--

"If to err is human, then I must be some kind of human!" -Me
 
How are ya krets . . .
krets said:
[blue]This form works as I want it to. [purple]You can select values in multiple combo boxes and it allows the user to build their filter slowly.[/purple][/blue]
I don't know how [surprise] as the combo's have to be concatenated together with [blue]and/or[/blue] logic operatrors in a single string for it to work the way you want. At present your just changing the filter per selected combo. End result should be something like:
Code:
[blue]   Me.Filter = (Combo1Criteria) AND (Combo2Criteria) AND (Combo3Criteria)[/blue]
If you post sample criteria for each combo we can show you how its done! . . . don't forget to state your [blue]and/or[/blue] logic! . . .

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top