match by first few letters

C

cherrynich

I have a query that runs off a form, where I have to enter a name. i want to
be able to enter the first few letters of the name and have it return the
name, I know there is a way to do it, I've done it before. Will someone clue
me in. Thanks a lot
Nick
 
D

Douglas J. Steele

You need to use LIKE (rather than =) and include a wildcard symbol (usually
*) after the letters:

SELECT Field1, Field2
FROM MyTable
WHERE Name LIKE "cher*"
 
C

cherrynich

I can't have my user's changing sql code I need something that I can enter
maybe into query criteria or SQL once. because there are 50 different
technicians queried a day I can't go in and change that 50 times I've got too
many users. I need it to find anything that starts with the first 3 letters
or so I enter. I really appreciate your input. thank you.
 
D

Douglas J. Steele

There's no need to hard-code it.

SELECT Field1, Field2
FROM MyTable
WHERE Name LIKE [First 3 Letters?] & "*"

will pop up a dialogue box that they can type letters into and it'll use
that as a criteria.

Alternatively, you could put a combobox on a form and let them pick their
name from the list, then use that to run your queries.
 
Top