Filtering a form with mulitple combo boxes

teric2

Registered User.
Local time
Today, 13:02
Joined
Feb 20, 2010
Messages
32
Hello All!

I want to open a form that is filtered by the selections made from another form with three combo boxes. I have this so far to filter from one of the combo boxes how do I filter using all three combo boxes.

wclause = "[date] = #" & Me![Combo2] & "#"

DoCmd.OpenForm "Record_Find_Press", , , wherecondition:=wclause

there would be a combo3 & combo4 that are text and I would like the form to filter by the selection in all three boxes.


Thank You!
 
Last edited:
You just need to expand the wclause criteria string by concatenation to include values from the combo3/4
If Len(Me.combo3)>0 Then: wclause = wclause & " And " [field3] = ' " & Me.combo3 & " ' "
If Len(Me.combo4)>0 Then: wclause = wclause & " And " [field4] = ' " & Me.combo4 & " ' "
Where field3/4 are fields in the table/query that drive the second form. Each combo is tested to see if it holds a value before adding it to the criteria string
David
 
You just need to expand the wclause criteria string by concatenation to include values from the combo3/4
If Len(Me.combo3)>0 Then: wclause = wclause & " And " [field3] = ' " & Me.combo3 & " ' "
If Len(Me.combo4)>0 Then: wclause = wclause & " And " [field4] = ' " & Me.combo4 & " ' "
Where field3/4 are fields in the table/query that drive the second form. Each combo is tested to see if it holds a value before adding it to the criteria string
David

Thank you for your reply and sorry for taking so long to respond.

I'm getting an "expected: end of statement" error with your code at the [field3] point.
I copied your code then edited it to reflect the correct field names and combo box names and pasted it right below my wclause.

wclause = "[date] = #" & Me![Combo2] & "# "
If Len(Me.Combo0) > 0 Then: wclause = wclause & " And " [press_number] = ' " & Me.Combo0 & " ' "
 
Sorry looks as if I may have missed some '&'s, try:
If Len(Me.Combo0) > 0 Then: wclause = wclause & " And " & [press_number] & " = ' " & Me.Combo0 & " ' "
David
 
Sorry looks as if I may have missed some '&'s, try:
If Len(Me.Combo0) > 0 Then: wclause = wclause & " And " & [press_number] & " = ' " & Me.Combo0 & " ' "
David

I know this post is a few days old but this is still not working for me. I'm not getting any errors it just doesn't do anything when I click the command button on the form with this code in the on click event:

wclause = "[date] = #" & Me![Combo2] & "# "
If Len(Me.Combo0) > 0 Then: wclause = wclause & " And " & [press_number] & " = ' " & Me.Combo0 & " ' "
DoCmd.OpenForm "Record_Find_Press", , , wherecondition:=wclause

The form doesn't even open.

Thanks for any additional help I can get.
 
Ok I have this resolved and here is the code that works


wclause = "[date] = #" & Me![Combo2] & "# "
If Len(Me.Combo0) > " " Then: wclause = wclause & " And " & "[press_number] = '" & Me.Combo0 & "'"

Thanks for the information.
 

Users who are viewing this thread

Back
Top Bottom