Results 1 to 6 of 6

Thread: Simple Access Autonumber Question

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Exclamation

    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

  2. #2
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Cool Yes...

    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?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Cool Thats great but what about .....

    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

  4. #4
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Lightbulb You could try...

    The 'DataFormat' property on a VB text box.

    Go to the 'Custom' option and try putting in five zero's there.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Arrow Not there !!

    I can't find the Dataformat property, maybe its because I am using VB5....

    Steve

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178

    Thumbs up Ok, A workaround

    Thanks for all the help simonm...

    I just used this in the end

    Code:
    Private Sub TxtFields_Change(Index as integer)
    
    me.txtfields(0).Text = Format(Me.txtfields(0).text,"00000")
    
    End sub
    Cheers
    Steve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width