Filtered data based on two combo boxes

flying linus

Registered User.
Local time
Yesterday, 19:25
Joined
Oct 1, 2004
Messages
33
I am trying to filter data on a form based on user selection of criteria from two independent combo-boxes. Here is the code I have so far:

Private Sub Combo9_AfterUpdate()
Forms![frmDF_AV_Fail_Cases_Summary].Form.Filter = "[1st_Fail_Domain] = '" & Me![Combo9] & "'"
Form_frmDF_AV_Fail_Cases_Summary.Form.FilterOn = True
End Sub

Private Sub Combo11_AfterUpdate()
Forms![frmDF_AV_Fail_Cases_Summary].Form.Filter = "[2nd_Fail_Domain] = '" & Me![Combo11] & "'"
Form_frmDF_AV_Fail_Cases_Summary.Form.FilterOn = True
End Sub

How do I get the form to filter based on the first selection and the second selection? Right now they both perform independently.
 
Flying,

Code:
Me.Filter = "[1st_Fail_Domain] = '" & Me.Combo9 & "' And "
            "[2nd_Fail_Domain] = '" & Me.Combo11 & "'"

Wayne
 
OK...I understand the logic and have tried several variants, but keep getting a syntax error or run time error. Here is exactly what I have...

Private Sub Combo11_AfterUpdate()

Me.Filter = "[1st_Fail_Domain] = '" & Me.Combo9 & "' And " "[2nd_Fail_Domain] = '" & Me.Combo11 & "'"

End Sub
 
fl,

Probably punctuation.

SQL needs to be told what type of data it is:

Sample for string, date, number (in that order)

Me.Filter = "[1st_Fail_Domain] = '" & Me.Combo9 & "'"
Me.Filter = "[1st_Fail_Domain] = #" & Me.Combo9 & "#"
Me.Filter = "[1st_Fail_Domain] = " & Me.Combo9

Wayne
 
I have tried each of the examples you have given and still get the Runtime Error 13 - Data Mismatch.

Each filter works independently, but when I try to filter based on both conditions, it doesn't work.

Each of the combo boxes are text fields, and carefully looked at the syntax. I'm stuck.

I appreciate all the help so far and has helped me with other items, but would like to get this one function to work.

Thanks.
 
fl,

Can you post the line that is giving you the error?

Wayne
 
Actual line giving the error:

Me.Filter = "[1st_Fail_Domain] = '" & Me.Combo9 & "'" And Me.Filter = "[2nd_Fail_Domain] = '" & Me.Combo11 & "'"

Actual error:

"Run Time Error: 13
Type Mismatch"
 
fl,

This works if they're both strings, if one of them is a number, remove the
single-quotes from it (not the other one, too).

Code:
Me.Filter = "[1st_Fail_Domain] = '" & Me.Combo9 & "' And [2nd_Fail_Domain] = '" & Me.Combo11 & "'"

Wayne
 

Users who are viewing this thread

Back
Top Bottom