Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

autonumber field format

Status
Not open for further replies.

amna77

Programmer
May 27, 2003
69
0
0
GB
Hi on my form, I have one autonumber field. is there anyway that I format autonumber field, so it gives me YYYYMMDD-###, I want current date like year, month and day and then - ###, about ###, every day I want to start with 001. for exaple if they enter 3 record per day, then it should be YYYYMMDD-001, YYYYMMDD-002, YYYYMMDD-003. and then next day these ### going to start again 001, 002, etc.
Please help me with that. i shall be thankful to you.
Thanks in advance
Amna
 
About the only way you can do this is to store your number in a table (you aren't going to be able to use the autonumber field). In the BeforeUpdate event of the form, read the record to get the value, increment it by 1 and write the new number back to the record. Then set your field to:

strField = format(date,"yyyymmdd") & "-" & NumberFromRecord
 
I agree autonumber doesn't apply here. I would also suggest that the table to store the number should have two fields: MyIndexNumber and MyIndexDate. If you find the record's MyIndexNumber field value is 5 but MyIndexDate is not today, I would set NumberFromRecord = 1 and MyIndexNumber will be reset to 2 for the next number and MyIndexDate is reset to today. In this way, the number will always start from 1 again on a new date. If you like to show 001 instead of 1 use: Right("000" & NumberFromRecord,3) so that 7 will show as 007.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top