Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding leading zeroes

Status
Not open for further replies.

rockiwood

MIS
Apr 17, 2002
50
GB
I am trying to add leading zeroes to a number in a work order. The incrementing part works fine. When i try to add the leading zeroes, it doesn't work. I am assuming that because it is a number it is stripping the leading zeroes.

WONumber = Right(DMax("fldwo", "tblAvionicsMainWO"), Len(DMax("fldwo", _
"tblAvionicsMainWO")) - InStr(1, DMax("fldwo", "tblAvionicsMainWO"), "-")) + 1
WONumber = Format(WONumber, "0000")
The last line is the one i can't get to work.

Any help is appreciated.

Thanks in advance
 
Leading zeros are a formatting thing ... not a data value thing. The line "doesn't work" because the format command is pre-pending the leading zeros and then that is being converted to a numeric (the data type of WONumber) which ignores them. If you actually want to store leading zeros then you will need to make the field a text field.
 
rockiwood,
At least in Access tables, setting the format to 0000 will cause the leading zeroes to be shown. Is there more to your code, if so, can you show us that? If you add this line, what get's displayed in your Immediate Window?

WONumber = Format(WONumber, "0000")
Debug.Print WONumber


Where are you displaying WONumber that it is not showing the leading zeroes?


I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Thanks!

I got it. I converted it to a string and it works as advertised.

Jerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top