Query by form using "like"

TimTDP

Registered User.
Local time
Today, 16:41
Joined
Oct 24, 2008
Messages
213
On a form I have a list box with the following recordset:
Code:
SELECT tblCustomer.CustomerID, tblCustomer.CustomerName
FROM tblCustomer
WHERE (((tblCustomer.CustomerName) Like [Forms]![Form1]![txtCompanyName] & "*"))
ORDER BY tblCustomer.CustomerName;

Also on the form I have a text box called "txtCompanyName"
The On Change event is: Me.List0.Requery

What I want is to filter the list box as characters are entered into the text box.

For example, if the user enters Bar into the text box, all customer names beginning with Bar will be displayed in the list box.

But it does not work!

any suggestions on why not?

Thanks
 
Try this:


Code:
SELECT tblCustomer.CustomerID, tblCustomer.CustomerName
FROM tblCustomer
WHERE (((tblCustomer.CustomerName) Like [Forms]![Form1]![txtCompanyName][B][COLOR="Red"].[Text][/COLOR][/B] & "*"))
ORDER BY tblCustomer.CustomerName;

Steve.
 
Perfect. Thank you
 

Users who are viewing this thread

Back
Top Bottom