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
Solved

Access query to remove leading zeros

Posted on 2013-01-29
2
499 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

829 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