P
Peter Myers
I am creating a form that records incidents that occur at my work. I am
trying to create a field that will automatically generate an incremented
serial number based on the year. For instance, the 18th incident of 2008 will
automatically be logged as "2008/18". The catch is that the "/XX" part has to
revert back to 1 for each new year, so that the first incident of 2009 will
then be automatically logged as "2009/1".
I have tried the following;
Inserted a field into the table ("IncidentTester") named [Increment]. The
date field in the table is named [IncidentDate]. The serial number field that
I want to be autogenerated is called [IncidentNumber].
I have created a field for each of these on the form called [txtIncrement]
and [txtIncidentDate].
I have made the default value for [txtIncidentDate] =Now()
The default value for [txtIncrement] is as follows
=Nz(DMax("[Increment]","IncidentTester",DatePart("yyyy",[IncidentDate])=DatePart("yyyy",Now())),0)+1
and the default value for [IncidentNumber] is
=DatePart('yyyy',[txtIncidentDate]) & "/" & [txtIncrement]
The problem I have is that [txtIncrement] is not resetting when I change the
system clock to 2009, even though the date field (set as Now()) IS resetting.
Everything seems to be working fine aside from this. Any help in this regard
would be greatly appreciated.
trying to create a field that will automatically generate an incremented
serial number based on the year. For instance, the 18th incident of 2008 will
automatically be logged as "2008/18". The catch is that the "/XX" part has to
revert back to 1 for each new year, so that the first incident of 2009 will
then be automatically logged as "2009/1".
I have tried the following;
Inserted a field into the table ("IncidentTester") named [Increment]. The
date field in the table is named [IncidentDate]. The serial number field that
I want to be autogenerated is called [IncidentNumber].
I have created a field for each of these on the form called [txtIncrement]
and [txtIncidentDate].
I have made the default value for [txtIncidentDate] =Now()
The default value for [txtIncrement] is as follows
=Nz(DMax("[Increment]","IncidentTester",DatePart("yyyy",[IncidentDate])=DatePart("yyyy",Now())),0)+1
and the default value for [IncidentNumber] is
=DatePart('yyyy',[txtIncidentDate]) & "/" & [txtIncrement]
The problem I have is that [txtIncrement] is not resetting when I change the
system clock to 2009, even though the date field (set as Now()) IS resetting.
Everything seems to be working fine aside from this. Any help in this regard
would be greatly appreciated.