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 » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query help for zip codes



 
 
Thread Tools Display Modes
  #1  
Old February 13th, 2010, 12:02 AM posted to microsoft.public.access.gettingstarted
BARRY
external usenet poster
 
Posts: 383
Default Query help for zip codes

My table has several thousand 9-digit zip codes (like 90210-2345). I want to
create a query whereby all 5-digit zips are grouped together at the top (or
bottom) so that I can research them and convert them to 9-digit. I think it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like this:
substring(zip,8)=" ". Any help would be appreciated.
--
Barry
  #2  
Old February 13th, 2010, 12:20 AM posted to microsoft.public.access.gettingstarted
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Query help for zip codes

Hello Barry,

Put the following expression in an empty field in the query:
Len([Zipcode])
This will be a list of 5s and 9s. Sort ascending and you will have all the
5s at the top.

Steve



"Barry" wrote in message
...
My table has several thousand 9-digit zip codes (like 90210-2345). I want
to
create a query whereby all 5-digit zips are grouped together at the top
(or
bottom) so that I can research them and convert them to 9-digit. I think
it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like
this:
substring(zip,8)=" ". Any help would be appreciated.
--
Barry



  #3  
Old February 13th, 2010, 12:21 AM posted to microsoft.public.access.gettingstarted
Rick Brandt
external usenet poster
 
Posts: 4,354
Default Query help for zip codes

Barry wrote:

My table has several thousand 9-digit zip codes (like 90210-2345). I want
to create a query whereby all 5-digit zips are grouped together at the top
(or bottom) so that I can research them and convert them to 9-digit. I
think it's a "Mid" kind of thing, but I'm not sure. In dBase, it was an
index like this: substring(zip,8)=" ". Any help would be appreciated.


SELECT *
FROM TableName
ORDER BY Len(ZipCodeField)
  #4  
Old February 13th, 2010, 12:23 AM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default Query help for zip codes

To just get the records where the zip is exactly five number characters you
can use.

Field: Zip
Criteria: Like "#####"

Or to get any/all that are not five digits, a dash, and four digits

Criteria: NOT Like "#####[-]####"

To sort the records you could add a calculated field (length of zip) and then
sort by the length.
Field: Len([Zip])


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

Barry wrote:
My table has several thousand 9-digit zip codes (like 90210-2345). I want to
create a query whereby all 5-digit zips are grouped together at the top (or
bottom) so that I can research them and convert them to 9-digit. I think it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like this:
substring(zip,8)=" ". Any help would be appreciated.

  #5  
Old February 13th, 2010, 12:35 AM posted to microsoft.public.access.gettingstarted
fredg
external usenet poster
 
Posts: 4,386
Default Query help for zip codes

On Fri, 12 Feb 2010 16:02:01 -0800, Barry wrote:

My table has several thousand 9-digit zip codes (like 90210-2345). I want to
create a query whereby all 5-digit zips are grouped together at the top (or
bottom) so that I can research them and convert them to 9-digit. I think it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like this:
substring(zip,8)=" ". Any help would be appreciated.


Is the hyphen stored with the zip code?
Either way, the below SQL will return all Zips that are 6 or less
characters in length sorted by Zip.

SELECT YourTable.Namfield, YourTable.ZIP, Len([Zip]) AS Exp
FROM YourTable
WHERE (((Len([Zip]))=6))
ORDER BY YourTable.ZIP;

If you want all zips (regardless of 5 or 9 characters) with all the 5
character zips on top, then:

SELECT YourTable.[Last Name], Len([Zip]) AS Exp,YourTable.ZIP
FROM YourTable
ORDER BY Len([Zip]), YourTable.ZIP;



--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #6  
Old February 14th, 2010, 03:41 PM posted to microsoft.public.access.gettingstarted
BARRY
external usenet poster
 
Posts: 383
Default Query help for zip codes


--
Barry


"Steve" wrote:

Hello Barry,

Put the following expression in an empty field in the query:
Len([Zipcode])
This will be a list of 5s and 9s. Sort ascending and you will have all the
5s at the top.

Steve



"Barry" wrote in message
...
My table has several thousand 9-digit zip codes (like 90210-2345). I want
to
create a query whereby all 5-digit zips are grouped together at the top
(or
bottom) so that I can research them and convert them to 9-digit. I think
it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like
this:
substring(zip,8)=" ". Any help would be appreciated.
--
Barry



.

  #7  
Old February 14th, 2010, 07:04 PM posted to microsoft.public.access.gettingstarted
BARRY
external usenet poster
 
Posts: 383
Default Query help for zip codes


--
Barry


"Steve" wrote:

Hello Barry,

Put the following expression in an empty field in the query:
Len([Zipcode])
This will be a list of 5s and 9s. Sort ascending and you will have all the
5s at the top.

Steve



"Barry" wrote in message
...
My table has several thousand 9-digit zip codes (like 90210-2345). I want
to
create a query whereby all 5-digit zips are grouped together at the top
(or
bottom) so that I can research them and convert them to 9-digit. I think
it's
a "Mid" kind of thing, but I'm not sure. In dBase, it was an index like
this:
substring(zip,8)=" ". Any help would be appreciated.
--
Barry



.

  #8  
Old February 14th, 2010, 07:08 PM posted to microsoft.public.access.gettingstarted
BARRY
external usenet poster
 
Posts: 383
Default Query help for zip codes


Steve,
Doing what you suggested:
Barry

Len([Zipcode])


returned nothing. Should there be something after the above? like =5 ?



  #9  
Old February 14th, 2010, 08:25 PM posted to microsoft.public.access.gettingstarted
Steve[_77_]
external usenet poster
 
Posts: 1,017
Default Query help for zip codes

Sorry Barry,

Put this expression in an empty field in your query:

5And9Zipcode:Len([Zipcode])

I have assumed "Zipcode" is the name of the zipcode field in your table. If
the name is something else, replace "ZipCode" on the right side of my
expression with your name.

Steve


"Barry" wrote in message
...

Steve,
Doing what you suggested:
Barry

Len([Zipcode])


returned nothing. Should there be something after the above? like =5 ?





  #10  
Old February 14th, 2010, 09:25 PM posted to microsoft.public.access.gettingstarted
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Query help for zip codes

On Sun, 14 Feb 2010 11:08:01 -0800, Barry
wrote:


Steve,
Doing what you suggested:
Barry

Len([Zipcode])


returned nothing. Should there be something after the above? like =5 ?



Where did you put this expression, Barry?
--

John W. Vinson [MVP]
 




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 10:51 AM.


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