?
Solved

Access query to remove leading zeros

Posted on 2013-01-29
2
Medium Priority
?
504 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 85
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 48

Accepted Solution

by:
Dale Fye earned 1600 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

777 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