Custom Autonum values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ssb

    #1

    Custom Autonum values

    Hello,

    I need to have a column in MS-Access table, which will be an
    autonumber of the type LNNN.

    (NNN is a number and 'L' is just an alphabet)

    This column is also the primary key. In other words, I need values
    like L001, L002 etc for consecutive records.

    How do I go about it?

    Thanks.
  • J. Paul Schmidt

    #2
    Re: Custom Autonum values

    <<
    I need to have a column in MS-Access table, which will be an
    autonumber of the type LNNN.

    (NNN is a number and 'L' is just an alphabet)

    This column is also the primary key. In other words, I need values
    like L001, L002 etc for consecutive records.

    How do I go about it?

    Thanks.[color=blue][color=green]
    >>[/color][/color]

    Either have a function that creates the new value for the text field each time
    a new record is being entered or just don't include the L in the field at all
    for the numeric field and only show the L on forms and reports but not as part
    of the field to be entered.

    And if you know the first character is always one character wide and the
    numeric part is always the last 3 characters:

    The first character can be referenced:
    Left([MyField], 1)

    And the last 3 characters:
    Right([MyField], 3)

    Or you may want to check for Null first perhaps doing something like this:
    If Not IsNull([MyField]) Then
    TheLeftPart = Left([MyField], 1)
    Else
    TheLeftPart = ""
    End If
    Best regards,
    J. Paul Schmidt, Freelance Access and ASP Web Developer

    Classic ASP Design Tips, ASP Web Database Demo, ASP Bar Chart Tool...

    Comment

    Working...