How do I search for a name using just the first letter of the last name?

M

Mike Webb

Using Access 2002. Experience level: Beginner
====================================
I am trying to write a Select query using SQL to retrieve all records with
last names beginning with a user-typed letter. (I'll put this on a search
form.) Just playing around with the below, I go it to work as is to return
all records with last names starting with 'A'. What I would like to do is
change this to a prompt of some sort that 'forces' the user to type in a
letter to run the query. I've searched Help and tried everything I could
find - no luck. I'm sure it's an easy one, but it is escaping me. Can
someone point me in the right direction?

SELECT [tblAddressList.LastName] & ', ' & [tblAddressList.FirstName] & ' '
& [tblAddressList.MiddleInitialName] AS FullName
FROM tblAddressList
WHERE ((([tblAddressList.LastName]) Like "A"));

TIA,
Mike Webb
 
F

fredg

Using Access 2002. Experience level: Beginner
====================================
I am trying to write a Select query using SQL to retrieve all records with
last names beginning with a user-typed letter. (I'll put this on a search
form.) Just playing around with the below, I go it to work as is to return
all records with last names starting with 'A'. What I would like to do is
change this to a prompt of some sort that 'forces' the user to type in a
letter to run the query. I've searched Help and tried everything I could
find - no luck. I'm sure it's an easy one, but it is escaping me. Can
someone point me in the right direction?

SELECT [tblAddressList.LastName] & ', ' & [tblAddressList.FirstName] & ' '
& [tblAddressList.MiddleInitialName] AS FullName
FROM tblAddressList
WHERE ((([tblAddressList.LastName]) Like "A"));

TIA,
Mike Webb

Are you sure you query was returning records starting with "A" ?
It shouldn't have.

Try:
WHERE ((([tblAddressList.LastName]) Like [Enter Initial] & "*"));
 
M

Mike Webb

Whoops. Should be "A*"

Just tested it again. Got 54 records back with last names starting with A.
(Out of 1800+)

fredg said:
Using Access 2002. Experience level: Beginner
====================================
I am trying to write a Select query using SQL to retrieve all records with
last names beginning with a user-typed letter. (I'll put this on a search
form.) Just playing around with the below, I go it to work as is to return
all records with last names starting with 'A'. What I would like to do is
change this to a prompt of some sort that 'forces' the user to type in a
letter to run the query. I've searched Help and tried everything I could
find - no luck. I'm sure it's an easy one, but it is escaping me. Can
someone point me in the right direction?

SELECT [tblAddressList.LastName] & ', ' & [tblAddressList.FirstName] & ' '
& [tblAddressList.MiddleInitialName] AS FullName
FROM tblAddressList
WHERE ((([tblAddressList.LastName]) Like "A"));

TIA,
Mike Webb

Are you sure you query was returning records starting with "A" ?
It shouldn't have.

Try:
WHERE ((([tblAddressList.LastName]) Like [Enter Initial] & "*"));
 

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