I have a simple table & form
the table has a created date field (value is set by default when the record created)
and Openeddate field (value is inputted as datetime)
I have a Counter Field which I want to set as 3 digits
so that the first record inputed which has a openeddate of say 01/01/2011
holds the value 001. (the leading zeros are important to me)
the next record inputted with the same opendate is 002
And the next record inputted for an opendate that does not exist in the table is 001
I have been playing with Dmax
But I cant get this to work.
the table has a created date field (value is set by default when the record created)
and Openeddate field (value is inputted as datetime)
I have a Counter Field which I want to set as 3 digits
so that the first record inputed which has a openeddate of say 01/01/2011
holds the value 001. (the leading zeros are important to me)
the next record inputted with the same opendate is 002
And the next record inputted for an opendate that does not exist in the table is 001
I have been playing with Dmax
Code:
Private Sub Ctl3DigitCode_BeforeUpdate(Cancel As Integer)
Me![3DigitCode] = Nz(DMax("[3DigitCode]", "[Main]", "[DateOpened]"), 0) + 1
End Sub
But I cant get this to work.