Create "autonumber" with date

S

shaggles

Is it possible to generate numbers that starts with the
current month and year and then adds 001, 002,etc.? I
want to end up with something that looks like 200407001.
 
R

Rick Brandt

shaggles said:
Is it possible to generate numbers that starts with the
current month and year and then adds 001, 002,etc.? I
want to end up with something that looks like 200407001.

Possible, but better to use two separate fields, one a Date and one a
number. Then you can *display* them on forms and reports using an
expression like...

=Format([DateFIeld], "yyyymm") & Format(NumberField],"000")
 
M

Margaret Bartley

dim i as integer, s as string
[initialize i, or retrieve it from where it is stored]

If i > 998 Then
Msgbox ("You have exceeded the daily limit of 999
transactions",vbOK)
Else
i = i + 1
s = Format(Date, "yyyymmdd") & Format(i, "000")
End If
 
G

Guest

How do I initialize i?
-----Original Message-----
dim i as integer, s as string
[initialize i, or retrieve it from where it is stored]

If i > 998 Then
Msgbox ("You have exceeded the daily limit of 999
transactions",vbOK)
Else
i = i + 1
s = Format(Date, "yyyymmdd") & Format(i, "000")
End If




shaggles said:
Is it possible to generate numbers that starts with the
current month and year and then adds 001, 002,etc.? I
want to end up with something that looks like 200407001.


.
 
M

Margaret Bartley

Depends on what you want to do.

i=1 is one way.

If you want to start at 1 every day, and the program will be
shut down and started throughout the day,
then store each number, as it's used, in a system table,
along with the date, and every time you need to generate a
new number, check the date. If the current date is the same
as the entry in the table, increment the number, and then
when the record is saved, put the new number in your system
table. If the date in the system table is not today, start
i at 1.


How do I initialize i?
-----Original Message-----
dim i as integer, s as string
[initialize i, or retrieve it from where it is stored]

If i > 998 Then
Msgbox ("You have exceeded the daily limit of 999
transactions",vbOK)
Else
i = i + 1
s = Format(Date, "yyyymmdd") & Format(i, "000")
End If




shaggles said:
Is it possible to generate numbers that starts with the
current month and year and then adds 001, 002,etc.? I
want to end up with something that looks like
200407001.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top