post code / zip code search

S

Simon

I have a form based on a query that lets me seach customer by post
code

The code i use on the field i type the post code in is
Me.Requery
Me!PostCodeSearch.SetFocus
Me!PostCodeSearch.SelStart = Len(Me.PostCodeSearch)

Some of our post codes in our database have a space in them and some
do not, my current code does not let me search with a space in it. if
i press the space bar is just does not accept it

How do i wrtite the code to i can have a space it it like ST14 5GH
and not like ST145GH

Or a away by query will search for postcodes with or without a space


Thanks
 
S

Stefan Hoffmann

hi,

I have a form based on a query that lets me seach customer by post
code

The code i use on the field i type the post code in is
Me.Requery
Me!PostCodeSearch.SetFocus
Me!PostCodeSearch.SelStart = Len(Me.PostCodeSearch)
This is an incomplete example. The search itself is not triggered or
executed. Post a concise and complete example please.
How do i wrtite the code to i can have a space it it like ST14 5GH
and not like ST145GH
Given a continuous form with a TextBox called txtPostCodeSearch in the
forms header:

Private Sub txtPostCodeSearch_Change()

Dim PostCode As String

PostCode = Replace(txtPostCodeSearch.Value, " ", "")
PostCode = "'" & Replace(PostCode, "'", "''") & "'"
Me.RecordSource = "SELECT fieldList " & _
"FROM [yourCustomerTable] " & _
"WHERE Replace([PostCode], " ", "") = " & PostCode

End Sub


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top