Hi, Andrew.
Convert it to a string and concatenate it with a "0" character. If it's
always five characters, not beginning with zero, then a ControlSource of this
should do it:
= "0" & Str([YourAutoNumberField])
If it could be of variable length, you could use nested IIf statements,
checking the various cases of length, but it's cleaner to write a custom
function, which you can put in the form module you use it in, or in a
standalong module, if you might reuse it in another application. In the
latter case, declare the function Public:
Public Function FillLeadingZero(intValue As Integer) As String
Const intDesiredLength = 6
Dim inti As Integer, intCurLength As Integer
FillLeadingZero = Str(intValue)
intCurLength = len(FillLeadingZero)
For inti = 1 to (intDesiredLength - intCurLength)
FillLeadingZero = "0" & FillLeadingZero
Next inti
End Function
Then set your ControlSource to a call to the function, passing it the
AutoNumber field:
=FillLeadingZero([MyAutoNumberField])
To make the function more general, you could also pass the total string
length as a second parameter rather than making it a constant.
Hope that helps.
Sprinks
Andrew said:
I have an autonumber such as 50001, 50002, 50006 and would like to have it
displays on the form or report or query in the format with 1 leading zero:
050001, 050002, 050006...
Please help. Thanks much. (This newsgroup is a great help for me)