Apply multiple criteria filter

asu81

Registered User.
Local time
Today, 22:50
Joined
May 26, 2012
Messages
47
Hi!
I've got a form based on a table.

I would like to filter my form based on two combo boxes "cmb1" and "cmb2".

I want the filter to be applied when pressing a button. The button vba is:

Private Sub btnOK_Click()
Me.Filter = "field1= " & Me.cmb1 AND "field2= " & Me.cmb2
Me.FilterOn = True
End Sub

But when I press the button after choosing values in the combo boxes I get an error "incompatible types".

Both field1 and field2 are value types.

What am I doing wrong?
Thanks!
 
Your quotes and concatenation is off. Try

Me.Filter = "field1= " & Me.cmb1 & " AND field2= " & Me.cmb2
 
That helped, thanks!

To be honest I don't quite understand the purpose of the & and citations. Is there anywhere I can read about it?
 

Users who are viewing this thread

Back
Top Bottom