Using 'Like' In A Query with User Input

saross

Registered User.
Local time
Today, 00:19
Joined
Mar 4, 2003
Messages
120
I want to know whether you can use the 'Like' and wildcard expressions to create a query which includes user input.
For example, instead of querying WHERE Like "A*" can I create a query WHERE Like "[Formname]![Control]*" ?

Basically, I am developing a contacts management database and want a form where the user clicks on a letter of the alphabet and the form automatically filters to display only contacts whose surname begin with that letter. I thought the way to do taht would be to have the underlying query dependent on a text box which changed it's value dependent on what button the user clicked (a, b, c etc.) but I don't seem to be able to use the Like *... with user input...

Any ideas?
:)
 
Instead of using 'like' in the criteria of your query, try using Left$ - something like this:

Left$([control name],3)="A"

Use the build function to build it up and you shouldn't have any problems.
 
See if this helps

IMO
 

Attachments

WHERE YourField Like Forms![Formname]![Control] & "*"

If this is to be used in VB code rather than in the QBE grid, you will need a different quote structure.
 

Users who are viewing this thread

Back
Top Bottom