How do I set up a unique number?

D

Dane

Hi There,

I am setting up a basic Data Licence database. For each new record I enter
I want a unique number to appear at the top of my form that can not be
changed. I would like the number to be the date it is entered plus the auto
number so, YYMMDD-(auto number) eg 071001-1. I'm sure it's something simple
but I am only new to access.

I would really appreciate any help!

Thank you,
Dane
 
A

Arvin Meyer [MVP]

Unless something has changed in the newest version, you need to type
something in your form you dirty it.

Then add something like this to the Dirty event on your form:

Private Sub Form_Dirty(Cancel As Integer)
txtMyData = Format(Date(),"yymmdd") & "-" & Me.txtID
End Sub

where txtMyData is the name of the textbox which holds your number field
from the table, and txtID is the name of the textbox that holds your
autonumber field. Lock the txtMyData textbox so that no one can fiddle with
it. (Code doesn't care if you lock the interface).
 
Top