Solved

Access query to remove leading zeros

Posted on 2013-01-29
2
502 Views
Last Modified: 2013-01-29
I have a search button where user type in and find the detailed in the form but what user does is when there are leading zeros like 0005,user type in 5 only and for 00222,user type in 222 but my query works only when user type in whole number like 00222 and 005.Please help as to make this query something like right function in sql.Thanks in advance

Here's my query-
SELECT [ABC].NNN
   ,[ABC].AAA
  FROM [ABC]
  WHERE ((([ABC].NNN) = [Enter AB]
         OR ([ABC].AAA) = [Enter AB]))
0
Comment
Question by:Josh2442
[X]
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
2 Comments
 
LVL 84
ID: 38833040
I would assume your values are NOT on stored with a Numeric Datatype (you can't store number with leading 0's), so you can just use a LIKE comparator:

SELECT * ABC WHERE [NNN] LIKE '*" & Me.YourSearchValue & "*'"
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 400 total points
ID: 38833042
SELECT [ABC].NNN ,[ABC].AAA
FROM [ABC]
WHERE [ABC].NNN Like "*" & [Enter AB] & "*"
OR [ABC].AAA Like "*" & [Enter AB] & "*"

Will get all those records where the characters entered in the input box are located anywhere within [AAA] or [BBB]
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

738 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