Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User entered value in filter

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello - I am fairly new to VBA. I am trying to filter a form containing property addresses. I would like the user to be able to type in the first few letters of the address and the form to then filter to the matching records. I have placed the data below on the click event of a button, but its not working. Whats wrong.

Also is this the right approach - I have reads up alot and see that often "I THINK", people seem to use

Select *
FROM Address
Where etc..

Is that a better approach?

My current code below:



Private Sub Btn_Find_DblClick(Cancel As Integer)

Me.Form.Filter = "[Property_Address_1] like'*" & [USER TYPES IN START OF ADDRESS] & "*'"
Me.FilterOn = True
Me.OrderBy = "[Property_Address_1] ASC, [Property_Address_no] ASC"
Me.OrderByOn = True

End Sub


Thank you Mark
 
Is [USER TYPES IN START OF ADDRESS] a TextBox in your form ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
No its not - I was hoping access would pop a box up to let the user filol date in here

Thanks Mark
 
Have a look at the InputBox function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks - I have now got the code wroking below - but it asks twice for the parameter - how can I avoid this? (I presume it is because the on Orderby is requesting it again, but I want it just to order by the field.

Me.Form.Filter = "[Property_Address_1] like '*'&[Type In Start of Property Address]&'*'"
Me.FilterOn = True
Me.OrderBy = "[Agreement_ID] DSC,[Property_Address_1] ASC"
Me.OrderByOn = True
 
Have a look here:
faq701-6763

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top