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

  • Thread starter Thread starter Mike Webb
  • Start date Start date
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
 
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] & "*"));
 
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] & "*"));
 
Back
Top