G
Guest
Access 2000 and 2003
I have data that looks like this:
Fields: ID (autonumber), year2dig (date field formatted "yy"), studynum
(long integer)
Data:
1,99,1
2,99,2
3,99,3
4,00,1
5,00,2
6,05,1
7,05,2
8,05,3
etc.
My users want to be able to continue to automatically increment the new
record studynum by one during a given year. Counting would start again at
the beginning of a new year.
As a beginning to work out out the code to do this, I am trying to simply
create a calculated field that will list the maximum studynum for the current
year. So since it is currently the year 2005, the maximum study number
should show as 3. I am using the DMAX function like this:
=dmax("[studynum]","tblMain","DatePart("yyyy",[year2dig])=DatePart("yyyy",Now())")
I know each part of the criteria portion of the dmax function works
individually, but strung together I'm getting an invalid syntax message.
I'll admit I have trouble with knowing where the quotes go.
I'd appreciate any suggestions on how to correct that code to show the
maximum study number for the current year (which I plan to add 1 to to get
the next study number).
Thank you,
Nicole
I have data that looks like this:
Fields: ID (autonumber), year2dig (date field formatted "yy"), studynum
(long integer)
Data:
1,99,1
2,99,2
3,99,3
4,00,1
5,00,2
6,05,1
7,05,2
8,05,3
etc.
My users want to be able to continue to automatically increment the new
record studynum by one during a given year. Counting would start again at
the beginning of a new year.
As a beginning to work out out the code to do this, I am trying to simply
create a calculated field that will list the maximum studynum for the current
year. So since it is currently the year 2005, the maximum study number
should show as 3. I am using the DMAX function like this:
=dmax("[studynum]","tblMain","DatePart("yyyy",[year2dig])=DatePart("yyyy",Now())")
I know each part of the criteria portion of the dmax function works
individually, but strung together I'm getting an invalid syntax message.
I'll admit I have trouble with knowing where the quotes go.
I'd appreciate any suggestions on how to correct that code to show the
maximum study number for the current year (which I plan to add 1 to to get
the next study number).
Thank you,
Nicole