debarton
asked on
How to default to next value for part of a field?
In my Access 97 database, I have a field Lab Number, of the format YYD/NNNN (e.g. 03D/1234). I want the form for entering new records only to allow the next lab number to be allocated, and to default to that number. For example, if the last sample was allocated 03D/1234, the next one must be 03D/1235. Lab Number is a text field with a validation rule: Like "##D/####"
ASKER
Thanks, Nic;o)
I would certainly prefer not to have to split this field, as I would have to do a lot of re-writing of queries, forms etc., because the Lab Number field comes up everywhere.
David
I would certainly prefer not to have to split this field, as I would have to do a lot of re-writing of queries, forms etc., because the Lab Number field comes up everywhere.
David
ASKER
Thinking about it some more, this wouldn't work anyway because the Lab Number starts at YYD/0001 each year, so we would end up with a whole load of duplicates if we took the YY out of the YYD/NNNN format.
David
David
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
YY
NNNN
The fixed "D" isn't really needed.
Showing the YYDNNNN code can be done using a stringing command in .g. a formfield like:
=YY & "D" & right("0000"&NNNN,4)
The "Right is to take care of possible leading zero's.
For a new Lab Number you can fill NNNN like:
me.NNNN=DMAX("NNNN","tblLa
Getting the idea ?
Nic;o)