Combining 2 Filters on a Form

Tallbloke

Registered User.
Local time
Today, 23:44
Joined
Aug 17, 2006
Messages
66
Ok this is driving me bonkers.

How do I combine these 2 onlick filters :

Code:
Private Sub ApplyTypeFilterBut_Click()

Dim FilterType As String
FilterType = "SupplierType =" & Me.TypeCombo.Column(0)
Me.Filter = FilterType
Me.FilterOn = True

End Sub

Code:
Private Sub LocationFilterBut_Click()

Dim FilterLocation As String
FilterLocation = Me.LocationFilter & "Tick"
Me.Filter = FilterLocation
Me.FilterOn = True

End Sub

So that I can apply both with 1 button.

Thanks in advance
 
Concatenate the two with " And " between them.
 
Concatenate the two with " And " between them.

I've tried combination of this and I can't for the life of me to get it to work.

Do you mean concatenate into one string OR change the Me.Filter = line?
 
I'd do the former, but either would work presuming the end result was a single string as the filter.
 
SO... would this work then :

Code:
Private Sub FilterBothBut_Click()

Dim FilterLocation As String
Dim FilterType As String
FilterType = "SupplierType =" & Me.TypeCombo.Column(0)
FilterLocation = Me.LocationFilter & "Tick"
Me.Filter = FilterLocation And FilterType
Me.FilterOn = True

End Sub
 
I think it should be:
Me.Filter = FilterLocation & " And " & FilterType
 
Gave this a try...

Code:
Private Sub ApplyAllFilterBut_Click()

Dim FilterLocation As String
Dim FilterType As String

FilterLocation = Me.LocationFilter & "Tick"
FilterType = "SupplierType =" & Me.TypeCombo.Column(0)

Me.Filter = Me.Filter = FilterLocation & " And " & FilterType
Me.FilterOn = True
  
  
End Sub

Anf I get just 1 blank form as the result.
 
How about

Me.Filter = FilterLocation & " And " & FilterType

If not, what does this produce in the Immediate window?

Debug.Print FilterLocation & " And " & FilterType
 
Oh..FFS how did i miss the double Me.Filter=

Thanks guys!

To add a third filter would I just use another instance of AND
 
No problem, and yes (you can also use OR, as appropriate to your needs).
 

Users who are viewing this thread

Back
Top Bottom