Leading Zeros

  • Thread starter Thread starter Kevin Labore
  • Start date Start date
K

Kevin Labore

Hello:

I have a table that has a Field (StockNum)
The field is Integer (not text)
The orderqty Field is Integer as well.

When used in forms and reports it of course supresses the leading Zeros, is
there an easy way to show the zeros?
The StockNum(Sku#) is a 4 digit # (so if the sku# = 123) I would want to
display 4 digits (ie. 0123) and the QTY always needs to be 2 digits ( so if
the orderqty was 6, it would need to be 06). The generated order needs to
display a 6 digit # based on sku# and orderty. (ie. 0123-06) Displaying a
dash or other character inbetween is fine to make it easier to read) So in
other words I am not trying to create a new number from the 2 numbers but
just displaying them together with the leading zeros?

thanks for any help

Kevin
 
Hello:

I have a table that has a Field (StockNum)
The field is Integer (not text)

Unless you'll be doing arithmatic with it, I'd suggest that it ahould be Text.
The orderqty Field is Integer as well.

As a quantity, Integer is appropriate - you will probably be summing or
averaging quantities. You won't be calculating the sum of all your StockNum
values though!
When used in forms and reports it of course supresses the leading Zeros, is
there an easy way to show the zeros?

Set the Format property to "0000" - or use a Text field and use "0000" as the
Input Mask.
The StockNum(Sku#) is a 4 digit # (so if the sku# = 123) I would want to
display 4 digits (ie. 0123) and the QTY always needs to be 2 digits ( so if
the orderqty was 6, it would need to be 06). The generated order needs to
display a 6 digit # based on sku# and orderty. (ie. 0123-06) Displaying a
dash or other character inbetween is fine to make it easier to read) So in
other words I am not trying to create a new number from the 2 numbers but
just displaying them together with the leading zeros?

Format([SKU#], "0000") & "-" & Format([orderqty], "00")

as the Control Source of a textbox should do what you want.

John W. Vinson [MVP]
 
Kevin said:
Hello:

I have a table that has a Field (StockNum)
The field is Integer (not text)
The orderqty Field is Integer as well.

First remember that an integer has no leading zeros .. ever.

It can be displayed with leading zeros. The place to do that is the
form or report where you or others will be viewing them

I would suggest that a "Stock Number) would normally be a text field as
it is not a "Number" rather it is an ID which could be numbers alpha
characters or a combination. That way you can store the ID in the manor in
which you want to display it, but of course you loose the ability to perform
math on it, like adding two together.
 
Thanks -- I would prefer Text as well but for sorting the stock #'s it
really needs to be integer. As text will sort differently.

Kevin
 
John W. Vinson said:
Unless you'll be doing arithmatic with it, I'd suggest that it ahould be
Text.


As a quantity, Integer is appropriate - you will probably be summing or
averaging quantities. You won't be calculating the sum of all your
StockNum
values though!

Due to the way the stock #'s are setup -- integers make them sort much
cleaner.
Otherwise I would convert the field to text.
Format([SKU#], "0000") & "-" & Format([orderqty], "00")

as the Control Source of a textbox should do what you want.

John W. Vinson [MVP]

Thanks John that is the format code I was looking for.(guess its been too
long since I worked with Access)

Kevin
 
Kevin Labore said:
Hello:

I have a table that has a Field (StockNum)
The field is Integer (not text)
The orderqty Field is Integer as well.

When used in forms and reports it of course supresses the leading Zeros,
is there an easy way to show the zeros?
The StockNum(Sku#) is a 4 digit # (so if the sku# = 123) I would want to
display 4 digits (ie. 0123) and the QTY always needs to be 2 digits ( so
if the orderqty was 6, it would need to be 06). The generated order needs
to display a 6 digit # based on sku# and orderty. (ie. 0123-06) Displaying
a dash or other character inbetween is fine to make it easier to read) So
in other words I am not trying to create a new number from the 2 numbers
but just displaying them together with the leading zeros?

thanks for any help

Kevin
 
Due to the way the stock #'s are setup -- integers make them sort much
cleaner.
Otherwise I would convert the field to text.

If you store it as text *with the leading zeros* it will sort correctly.

John W. Vinson [MVP]
 
Back
Top