Setting AutoNumber

jessiep

New member
Local time
Today, 03:49
Joined
Jul 6, 2006
Messages
7
How do I change an AutoNumber that will output 1, 2, 3 to output 0001, 0002, 0003??


Thanks
Jessie
 
AutoNumbers have no meaning other than to tag each record with an unique identifying number. The users should never see the autonumber. Create your own autonumber if you need otherwise. Search around for there are tons of threads related to your quest.
 
I just use it

Private Sub bqmaso_Exit(Cancel As Integer)
If Me.NewRecord = True Then
If RecordsetClone.RecordCount = 0 Then
Me.bqmaso = "000" + "1"
Else
Me.bqmaso = Right(("000" + CStr(DMax("[bqmaso]", Me.RecordSource) + 1)), 4)
End If
End If
End Sub

My best,
 
nhtuan,

Pretty Cool way to do it.

Me.bqmaso = Right(("000" + CStr(DMax("[bqmaso]", Me.RecordSource) + 1)), 4)
 
Cool doesn't always mean effecient. This is an old thread and MStCyr has already mentioned the best way of doing this. For the sake of completeness, you put "000"# in the Format property of the field or control, or use the Format() function.
 
vbaInet,

I was under the impression the original question wants the numbers to be 4 digits.

0009
0099
0999
9999

How would you do that with a format function or does "000"# in the Format property of the field or control do the above?

Thanks
 
VbaInet,

It always appends "000" to the beginning of the entry.

So if I type 100 -> "000100". The desired result is 100 -> "0100"

Assume the range of numbers is 1 - 9999 and the output must have 4 digits.

How would you do it without the Right Function?

Thanks
 
Just put

"0000"

in the format property and it will do the rest.

You don't need to concatenate on the number if the field is getting the number. Just have the four zeros.

If you want a number to be OPTIONAL you use # and if it has to be there you use 0.
 
Bob,

It worked when I excluded the "

so just 0000

Thanks
 
Sorry, I should have mentions I only included the quotes as a highlighter. You would include quotes if it was text, but a number - you do not use the quotes - correct.
 

Users who are viewing this thread

Back
Top Bottom