Problem readin Numbers

  • Thread starter Thread starter John
  • Start date Start date
J

John

my database has to be able to generate a VIN number. the
last 6 digits of that VIN is a serial number.

ex: 000083

the computer generates that fine, but when i read that
number to do multiplication to it, i can't get it to read
the zeros, it reads 83. i have to have those zeroes. i
realize that the above string as a number is 83, but i
need a autogenerated number, so as to not have the same
title VIN number. i am so frustrated!! thanks

John
 
John said:
my database has to be able to generate a VIN number. the
last 6 digits of that VIN is a serial number.

ex: 000083

the computer generates that fine, but when i read that
number to do multiplication to it, i can't get it to read
the zeros, it reads 83. i have to have those zeroes. i
realize that the above string as a number is 83, but i
need a autogenerated number, so as to not have the same
title VIN number. i am so frustrated!! thanks

John

Access looks at numbers two different ways. They can be numbers, which
you can add subtract etc. or they can be characters which it can not add
multiply etc.

Assuming they are really numbers (it seems you can perform calculations
so it would seem they are numbers) then do the math you want. As far as
Access is concerned a number 00083 is exactly the same as 83, except in one
case it has been told to display the number as "00000" format. Check out
the format property in the form, report or where ever you want to see the
leading zeros.

Now if you want to make up a VIN code like 00086SL78. You can do that
also, but it gets a little more complex and can be done several ways.
 
-----Original Message-----


Access looks at numbers two different ways. They can be numbers, which
you can add subtract etc. or they can be characters which it can not add
multiply etc.

Assuming they are really numbers (it seems you can perform calculations
so it would seem they are numbers) then do the math you want. As far as
Access is concerned a number 00083 is exactly the same as 83, except in one
case it has been told to display the number as "00000" format. Check out
the format property in the form, report or where ever you want to see the
leading zeros.

Now if you want to make up a VIN code like 00086SL78. You can do that
also, but it gets a little more complex and can be done several ways.
OK,
the problem is that it does display the number on the
form correct, but when i read it into VB to do the math
on the numbers is where i am not getting the zeros. that
is where i need the zeros to come. each number gets
multiplied by another number, each one of them different.
 
John said:
OK,
the problem is that it does display the number on the
form correct, but when i read it into VB to do the math
on the numbers is where i am not getting the zeros. that
is where i need the zeros to come. each number gets
multiplied by another number, each one of them different.

Leading zeros are not part of any math function. You don't need them to
do math, like multiplied by another number

00083
X 2
----------
00166


83
x2
-----
116

No difference

Now I am guessing you want the result to show "00116"

To do this you format the filed in the form to "00000"

From the Access help file: ~~~~~~~~~~~~~~~~~~~~~~~~~~


Format Property - Number and Currency Data Types
You can set the Format property to predefined number formats or custom
number formats for the Number and Currency data types.
Custom Formats
Custom number formats can have one to four sections with semicolons (;) as
the list separator. Each section contains the format specification for a
different type of number.
SectionDescription
FirstThe format for positive numbers.
SecondThe format for negative numbers.
ThirdThe format for zero values.
FourthThe format for Null values.


For example, you could use the following custom Currency format:
$#,##0.00[Green];($#,##0.00)[Red];"Zero";"Null"
This number format contains four sections separated by semicolons and uses a
different format for each section.
If you use multiple sections but don't specify a format for each section,
entries for which there is no format either will display nothing or will
default to the formatting of the first section.
You can create custom number formats by using the following symbols.


There is more in the help file, but this should get you started.

I hope that helps
 
Back
Top