Table has a field that is a counter.
When the record is deleted, the counter number becomes available again.
New records must use the lowest available "slot" for counter.
Example:
Material | Counter
00AF10 | 02
00AF11 | 03
00AF12 | 04
In this case, a new inserted record will take the counter number "01" and a new record after that, the counter number "05".
I've tried doing a select max counter + 1 as a new record, but that will of course fail the requirement of utilizing available "slots" in the counter sequence. I'm pulling an all nighter and my brain is fried. Can you help?