AutoNumber Help

M

Mike M

All,

I would like to create a field in my form that uses an
autonumber, but has a format of MMDDYYYY-xxxx where;
MM = 2 digit month
DD = 2 digit day
YY = 4 digit year
xxxx = unique number (autonumber)

However, I would like to see if the last part (xxxx) can
be reset back to 1 each new day.

TIA
Mike
 
M

Marshall Barton

Mike said:
I would like to create a field in my form that uses an
autonumber, but has a format of MMDDYYYY-xxxx where;
MM = 2 digit month
DD = 2 digit day
YY = 4 digit year
xxxx = unique number (autonumber)

However, I would like to see if the last part (xxxx) can
be reset back to 1 each new day.


This should be two fields in the form's record source table,
one for the date and the other for the sequential number.
The two values can be formatted and concatenated any way you
like at the time you want to display them to the user.

For a single user system, the code in the form's
BeforeInsert event procedure could look like:

Me.numberfield = NZ(DLookup("numberfield", "thetable", _
"datefield = " & Me.datefield), 0) + 1

Then the text box that displays the thing you want the users
to see can use an expression like:

=Format(datefield, "mm\/dd\/yyyy\-") & Format(numberfield,
"0000")
 
T

Tim Ferguson

I would like to create a field in my form that uses an
autonumber, but has a format of MMDDYYYY-xxxx where;

Just to amplify Marshall's comments, I would strongly recommend storing the
date part as a DateTime field. The huge disadvantage of a MMDDYYYY text or
number is that it won't sort in order without manipulating it back to
YYYYMMDD or all the way back to the original date.

Just a thought


Tim F
 

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

Top