Solved

Access query to remove leading zeros

Posted on 2013-01-29
2
496 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
2 Comments
 
LVL 84
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now