Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Monroeville, Pennsylvania, USA
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto fill in (2000)

    I need to have a field filled with a number of 0 automatically, if the number of characters is less than required. EXAMPLE: A serial number begins with 3 Alphanumeric characters 23Z for example,( there must be 8 characters in the field,) the last part may be 246. The number would then be 23Z246. This doesn't meet the requirements. It should look like this: 23Z00246. I need to have zeros (0) entered in the field when the total number of characters is less then required. There will always be three characters in the begining.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Auto fill in (2000)

    You can do this in a form. Let's say that you have a text box txtSerial. You can put code in the After Update event of the text box:

    Private Sub txtSerial_AfterUpdate()
    If Len(Me.txtSerial) < 8 Then
    Me.txtSerial = Left(Me.txtSerial, 3) & String(8 - Len(Me.txtSerial), "0") & Mid(Me.txtSerial, 4)
    End If
    End Sub

    An alternative would be to have separate fields for the first an last parts of the serial number int the table, and to calculate the complete serial number (including filler zeros) in a query.

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Location
    Monroeville, Pennsylvania, USA
    Posts
    152
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Auto fill in (2000)

    Thanks much. It works fine

Posting Permissions

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