Connecting Tech Pros Worldwide Help | Site Map

how to remove leading zeros from numbers when I do CTRL + F?

chris@whatsgoingcheap.com
Guest
 
Posts: n/a
#1: Apr 11 '06
Hi,

I have a simple ms access application that allows you to scan barcodes
in to a form which stores them in the database. The barcodes are 6
digits in length e.g. 555666 but my handheld scanner always adds a
leading zero - e.g. 0555666. You can get round this problem by
changing the database design for the field where this is stored from
text to number format.

However, when it comes to quickly doing a search for a code - CTRL + F
- the scanner still puts the code into the search box with the leading
zero. Is there a good way of stopping this? Would this be something I
could code via a macro?

(the long-term solution has to be to find the manual and scan a system
code that removes the leading zero)

Any suggestions??

Rich P
Guest
 
Posts: n/a
#2: Apr 12 '06

re: how to remove leading zeros from numbers when I do CTRL + F?


The start to finding a solution for your problem is to explain the
problem in a little bit more detail. When you say the scanner puts the
code into a search box - what is this searchbox? How does the data get
from the scanner get to the Access table? Obviously, there is some
serial port program that reads the data, and then you are retrieving the
value from this program. You need to intercept the data before it gets
to the table and cast the text value to a numeric value:

fldx = Int(valueFromScanner)

fldx = Int("00054321")

will store this value as 54321 in fldx

Rich

*** Sent via Developersdex http://www.developersdex.com ***
bruce@aristotle.net
Guest
 
Posts: n/a
#3: Apr 14 '06

re: how to remove leading zeros from numbers when I do CTRL + F?


There are a few solutions to this. The first is to simply store the
numbers as text, with the leading zeros intact.

Another less drastic approach would be to simply change the display
format of the numbers that you're storing. Go into table design view
and set the Format property of that field to 0000000. Now, even though
the numbers will display in your application with the leading zero,
what will be stored is simply the number minus the leading zeros. What
this will allow you to do is to use ctrl-f to find those numbers using
a bar code entry in the 'Find what:' box since they are being displayed
with a leading zero.

Last but not least you may want to build a custom 'find' form that has
the behavior you require.

Bruce

Closed Thread


Similar Microsoft Access / VBA bytes