Count Leading Zero

Posted on 2004-10-15
Last Modified: 2012-06-27
I'm using zip codes to sort and compile information and I have a query where I run an inventory of people in a 3 digit zip code range like this

Left([qryLastMail]![zip],3) AS 3DigZip

The problem I'm having is in the zip codes where there is a leading zero like in MA 01001 the query returns 100 instead of the 010. How can I get it to count the leading zero. The field is already formatted with 5 digits and when I do the query to show all five it returns the numbers with the leading zero just fine.
Question by:athomas79
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3

Expert Comment

ID: 12323106
left(cstr([qrylastmail]![zip],3) as 3digzip

Accepted Solution

mcorrente earned 500 total points
ID: 12323177
if not, try left(format([qrylastmail]![zip],"00000"), 3) as 3digzip

Author Comment

ID: 12323385
The changing it to a string didn't work, but formatting it again in the query before the taking left three digits worked great, Thanks!

Expert Comment

ID: 12323406
no problem.

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question