A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Help with a partial match query



 
 
Thread Tools Display Modes
  #1  
Old March 20th, 2010, 02:36 AM posted to microsoft.public.access.queries
Whirled.Peas
external usenet poster
 
Posts: 2
Default Help with a partial match query

I asked this question here many, many years ago and have since forgotten
the answer.

I have a table with address data in it, spread over several fields. One
of the fields is called "Zip" and is a text field of 5 characters in
length.

I am trying to write a query that will prompt the user to enter the first
FOUR digits of the zip code and have it return all matches for those four
characters.

For example, 1234 would return 12345, 12346, and 12347 and so on.

My recollection is that the query was something like:
SELECT * FROM addresses WHERE Zip LIKE "[Enter first four digits]%" but
that does not seem to work in Access 2007. I am probably misremembering.

Does anyone know the proper query syntax?

Thank you for your help.

--
If you try, you can envision peas on earth.
  #2  
Old March 20th, 2010, 03:23 AM posted to microsoft.public.access.queries
Gina Whipp
external usenet poster
 
Posts: 3,500
Default Help with a partial match query

Whirled.Peas,

I think what you looking for is...

LIKE "[Enter first four digits]" & "*"

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Whirled.Peas" wrote in message
...
I asked this question here many, many years ago and have since forgotten
the answer.

I have a table with address data in it, spread over several fields. One
of the fields is called "Zip" and is a text field of 5 characters in
length.

I am trying to write a query that will prompt the user to enter the first
FOUR digits of the zip code and have it return all matches for those four
characters.

For example, 1234 would return 12345, 12346, and 12347 and so on.

My recollection is that the query was something like:
SELECT * FROM addresses WHERE Zip LIKE "[Enter first four digits]%" but
that does not seem to work in Access 2007. I am probably misremembering.

Does anyone know the proper query syntax?

Thank you for your help.

--
If you try, you can envision peas on earth.

  #3  
Old March 20th, 2010, 01:24 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Help with a partial match query

whoops! Gina seems to have uncharacteristically gotten carried away with the
quotes.
LIKE [Enter first four digits] & "*"

You might need to replace the * with a % if you have set up your database to
use ANSII-compliant SQL.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Gina Whipp wrote:
Whirled.Peas,

I think what you looking for is...

LIKE "[Enter first four digits]" & "*"

  #4  
Old March 20th, 2010, 03:02 PM posted to microsoft.public.access.queries
Whirled.Peas
external usenet poster
 
Posts: 2
Default Help with a partial match query

On Sat, 20 Mar 2010 09:24:34 -0400, John Spencer wrote:

whoops! Gina seems to have uncharacteristically gotten carried away
with the quotes.
LIKE [Enter first four digits] & "*"

You might need to replace the * with a % if you have set up your
database to use ANSII-compliant SQL.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Gina Whipp wrote:
Whirled.Peas,

I think what you looking for is...

LIKE "[Enter first four digits]" & "*"


That did the trick! Thank you both for your help, it is very much
appreciated. It took me a few tries to get the proper number of quotes in
place, but John's string is correct.



--
If you try, you can envision peas on earth.
  #5  
Old March 20th, 2010, 05:00 PM posted to microsoft.public.access.queries
Gina Whipp
external usenet poster
 
Posts: 3,500
Default Help with a partial match query

Oh dear... THANKS John!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"John Spencer" wrote in message
...
whoops! Gina seems to have uncharacteristically gotten carried away with
the
quotes.
LIKE [Enter first four digits] & "*"

You might need to replace the * with a % if you have set up your database to
use ANSII-compliant SQL.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Gina Whipp wrote:
Whirled.Peas,

I think what you looking for is...

LIKE "[Enter first four digits]" & "*"

  #6  
Old March 20th, 2010, 05:01 PM posted to microsoft.public.access.queries
Gina Whipp
external usenet poster
 
Posts: 3,500
Default Help with a partial match query

Well, thank goodness John came along!

--
Gina Whipp
2010 Microsoft MVP (Access)

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

"Whirled.Peas" wrote in message
...
On Sat, 20 Mar 2010 09:24:34 -0400, John Spencer wrote:

whoops! Gina seems to have uncharacteristically gotten carried away
with the quotes.
LIKE [Enter first four digits] & "*"

You might need to replace the * with a % if you have set up your
database to use ANSII-compliant SQL.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Gina Whipp wrote:
Whirled.Peas,

I think what you looking for is...

LIKE "[Enter first four digits]" & "*"


That did the trick! Thank you both for your help, it is very much
appreciated. It took me a few tries to get the proper number of quotes in
place, but John's string is correct.



--
If you try, you can envision peas on earth.

  #7  
Old March 20th, 2010, 07:32 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Help with a partial match query

No problem. I've had a few* of my postings refined** by others.

* - an indeterminate number less than infinity
** - corrected politely sometimes with infinite patience.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Gina Whipp wrote:
Oh dear... THANKS John!

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:50 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.