Re: creating a an automatically incrementing, formatted reference number



You don't need a command button to do this; it can be done automatically!

In the table the form is based on, add a field named MyPrimaryKey and make
it autonumber and add MyPrimaryKey to your form. On your for, set the
default value of LabNumber to the following expression:
Format(Year(Date()),"YY") & "-" & Format([MyPrimaryKey],"0000")

PC Data***
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resource@xxxxxxxxxxxxxxx



"coldfire" <emspider0907@xxxxxxxxx> wrote in message
news:1183077176.528453.174710@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello, I'm new to access so please bare with me. I have created a
database which records information about cases, in this form is a lab
number column that i want to increment to the next unused number, with
the click of a command button on the form. The format that I want to
use for the lab number is 00-0000 the first two digits being the last
two digits of the year, and the other 4 digits incrementing with the
click of this button. I have tried vigorously to write code to do
this, however to no avail. Could someone please help me with this?

Thank you in advance,
coldfire



.