I would need a log number in the following format (Text-yy-nnn) where text is fixed series of letters denoting our office, yy is the last 2 digits of the year and nnn is a sequential number restarting each year. I am using Access 2007. The table is called
Document List, the date is stored in a field called Document Date formatted as Date() by default, and I have field for the log numbers - currently geenrated manually which is set as the primary key.
I have seen the blogs and the posting by Scott, and thus I have created a new field called Sequence set to number/long integer data type, and tried to insert the following code in the control bound to Sequence in the form:
Me.txtSequence=Nz(DMax("[Sequence]","tblDocument List","Year([Document Date])="&Year(Me.[txtDocument Date])),0)+1
The immediate window gave me the following error message: Expected:)
I also tried the following variant:
Me.Sequence=Nz(DMax("[Sequence]","Document List","Year([Document Date])="&Year(Me.Document Date)),0)+1
which returned the following: Expected: list separator or )
I am not sure where a ) can be missing, as all the brackets haev been closed, but there is apparently a problem with the syntaxt. I have seen that other bloggers trying this code have reported that they did not have any success either. I would really appreciate
fi you could help me with the above.
Also, if I understand Scott's instructions properly, the
=Format([Document Date],"yy")&"-"&Format([Sequence],"000")
code would then go into the field for the log number. Can I just insert it into the control in design mode?
Do I need the square brackets? Do I need to leave spaces anywhere?
Thanks for your help in advance!
ZsuM