Search for a value in a table from a form

sam77755

Registered User.
Local time
Yesterday, 22:18
Joined
Dec 7, 2004
Messages
23
:o

HI I am Looking for some help here...
1- I have a table that has a Postal code field.
2- a Query getting data from the table to a form.
3- a textbox in the form that the Onclick event is set to run the query based on the value I enter in an input box triggerd by the on click event code below.

Private Sub BDM_Click()
Dim intPostal As Variant

intPostal = InputBox("Please Enter Postal Code")
txtPostal = intPostal
DoCmd.OpenQuery "QryAvgIncome"


End Sub


Of course the qry is getting the inputbox value from the text box txtPostal

4- Canadian postal codes are always in this format L1L 1L1.
5- my problem is I am trying to enter a partial entry in the input box (i.e. L1L) and ask the query to return all matching results. I tried using the Like* in the query but again it didnt work, I belive the reason is that the field is built based on the input from the form.

Guys anyone knows how to overcome this problem?

thank you all

P.S. I am using Access 2003
 
Sam,

You don't need the InputBox, you can just use the AfterUpdate event of
txtPostal.

The query's Criteria should be:

Like "*" & Forms![YourForm]![txtPostal] & "*"

btw,
If your form is based on the above query, why are you do do a
DoCmd.OpenQuery instead of a Me.ReQuery for the form?

Wayne
 

Users who are viewing this thread

Back
Top Bottom