Click to See Complete Forum and Search --> : Simple Access Autonumber Question
Sforster
Sep 28th, 2000, 04:00 AM
Hi all,
Does anybody know how to format the autonumber of a field in Access?
What I want is a 5 digit Autonumber, whenever I select autonumber as the field datatype it always shows the actual number i.e. number 6 is 6....
I want 00006
Is that possible
Thanks for any help
Steve
simonm
Sep 28th, 2000, 04:58 AM
You can't change the autonumber format in the table itself but you can format the way it's displayed on a form or in a report.
In both Visual Basic and VBA there is a Format function that can be used to pad out a number with a specified number of zeros.
In Access form design there is a 'Format' property of a text box which, with the value '00000' will pad out your number so that five digits are always displayed.
Is this any help?
Sforster
Sep 28th, 2000, 05:18 AM
Yeah I understand that, but my textbox is in my VB application and it is bound to the field in Access.
In access it looks fine, but that formatting is not carried into my VB application. Which makes me thing why bother unless using VBA within Access?? (Maybe another question there)
And another here, What event would I place the Format code into....The form load
Cheers
steve
simonm
Sep 28th, 2000, 05:25 AM
The 'DataFormat' property on a VB text box.
Go to the 'Custom' option and try putting in five zero's there.
Sforster
Sep 28th, 2000, 05:59 AM
I can't find the Dataformat property, maybe its because I am using VB5....
Steve
Sforster
Sep 28th, 2000, 06:06 AM
Thanks for all the help simonm...
I just used this in the end
Private Sub TxtFields_Change(Index as integer)
me.txtfields(0).Text = Format(Me.txtfields(0).text,"00000")
End sub
Cheers
Steve
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.