Field Size Control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a field dim definition that will always be 5 postions long and zero
filled to the left. This is a counter that will count to approximate 10000
but needs to be 00001 then 00002 then 00003 and so on. Everything I have
tried ends up taking away the leading zeros. Even the initial equal line in
the program will automatically rewrite the statement ctr2 = 00001 to be ctr2
= 1. With each pass of the program logic I then need to be able to add 1 to
the value. Thank you for your help!
 
vtj said:
I need a field dim definition that will always be 5 postions long and
zero filled to the left. This is a counter that will count to
approximate 10000 but needs to be 00001 then 00002 then 00003 and so
on. Everything I have tried ends up taking away the leading zeros.
Even the initial equal line in the program will automatically rewrite
the statement ctr2 = 00001 to be ctr2 = 1. With each pass of the
program logic I then need to be able to add 1 to the value. Thank
you for your help!

A true number never actually stores any leading zeros -- it's just a
number, and leading zeros are a matter of formatting. For a field in a
table, or a control on a form or report, you can use the Format property
to have it *displayed* with leading zeros, if you want. An alternative
would be to use a text field, storing your zero-filled numeric values as
text, but then you'd have to do all the formatting yourself; e.g.,

Dim strNewValue As String

strNewValue = Format(Clng(Me!CtrField) + 1, "00000")

Me!CtrField = strNewValue
 
Back
Top