What should be a simple filter....

Tallbloke

Registered User.
Local time
Today, 23:14
Joined
Aug 17, 2006
Messages
66
I have a subform and I want to filter it by location.
In the header of the subform I have a dropdown that contains all the possible locations.
I then have a button with the following code :

Code:
Private Sub FilterLocBut_Click()
Dim Filtertown As String
Filtertown = "Location =" & Me.LocationCBO.Column(1)
Me.Filter = Filtertown
Me.FilterOn = True
End Sub

When I press the button I have a parameter box that appears and asks has the name of the location I selected above the input area. If I enter the name again, it works.

I.e. Select Brighton, click Button, Parameter box appears with the workd "Brighton" in it, if i type brighton into the box the filter works as expected.

I've checked and re-checked my spelling.
When I pause the code I get :

Me.Filter = "Location =Brighton" (for example)

The form filters just fine if I right click in the location field and select "Equals Brighton"

This is driving me bonkers ;)
 
Code:
Private Sub FilterLocBut_Click()
Dim Filtertown As String
Filtertown = "Location =" [B][COLOR=red]& Chr(34)[/COLOR][/B] & Me.LocationCBO.Column(1) [B][COLOR=red]& Chr(34)[/COLOR][/B]
Me.Filter = Filtertown
Me.FilterOn = True
End Sub

You could also use single quotes instead but I find it easiest to use the Chr(34) which is a double quote.
 

Users who are viewing this thread

Back
Top Bottom