I would like to have such a number because It will be a unique number for
every person. Furthermore my problem is that this number I would not like to
change and If it could be created automatically. For example if I have three
names such Smith Bound and Sound with numbers S1 for the first B1 for the
second and S2 for the third for a new record such as Brilliant would get B2.
Furthermore if I delete a person with S the new record will get the S3 Is
this possible
It's possible, and I'll describe how below.
But it is still A VERY BAD IDEA.
Such sequential numbers maybe made sense, fifty years ago, when they
were needed to put onto file drawers or as the Only Searchable Field
in a flat-file database. They make next to no sense today.
After you get records in the database for Brilliant, Bound, Brassy,
Bossanova, Buzz, and Bodacious - and you have B1, B2, B3, B4, B5, and
B6 - how will you know at a glance, or even with some research, which
is which? What *good* does a B5 label on the record tell you (other
than if it were a soundtrack to Babylon 5)? They will not be in
sequential order alphabetically (you don't want them to change, so if
you add "Baa Baa Blacksheep" three months from now it won't be B1); if
they're chronological, you won't be able to remember "Did I enter
Bound before entering Brilliant, or after?" I cannot see that it does
you ANY good.
That said... you can have an Integer field which I'll call SEQ in your
table. Do all your data entry using a Form. In the AfterUpdate event
of the name field (which should not be called NAME, since that's a
reserved word - I'll assume you have a textbox named txtNamefield, and
a textbox txtSeq) put code like:
Private Sub txtNamefield_AfterUpdate()
If Not IsNull(Me!txtNamefield) Then
Me!txtSeq = NZ(DMax("[Seq]", "[yourtable]", "[namefield] LIKE " _
& Left(Me!txtNamefield, 1) & "(*")) + 1
End If
End Sub
When you want to see the "B4" or whatever, use a calculated field in a
Query or in the control source of a form or report textbox:
Left([namefield], 1) & [seq]
John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps