How to generate my own autonumber?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I need to generate numbers with a certain format. I want to numbers to start with 01/04, 02/04, 03/04 etc, i.e. an increasing number followed by the year (number/year). Can anyone help me with this one

Cheers
 
I need to generate numbers with a certain format. I want to numbers to
start with 01/04, 02/04, 03/04 etc, i.e. an increasing number followed
by the year (number/year). Can anyone help me with this one?

Use two fields: you are storing two separate bits of information, after
all.

Have a field called CreateYear, set its DefaultValue to =Year(Date())

Have a second field called SerialNumber, and use a little bit of VBA behind
a form[1] to allocate it.

When you need users to see the combined number, you can use a text box on a
form or report with its ControlSource set to something like:

=Format(SerialNumber,"00") & "/" & Format(CreateYear,"00")

so that they will never know.

[1] If you need to incorporate a large number of different methods of
record creation -- eg import text files, SQL queries, VBA, Excel, etc --
then you may have to think about moving up to a real database like MSDE/
SQLServer etc. On the other hand, as long as you can make sure that nobody
can insert records except using your form, then Access will work fine.

Hope that helps


Tim F
 
Back
Top