Please do not use such an ID system as the primary key for linking records in one table to related records in others. Stick with a simple auto-entered serial number of Get ( UUID ) auto-entered value instead. Such a custom numbering system should only be employed when users require such and then you keep the value in the parent table for inclusion in reports and for searches/sorts, but not as a match field in relationships except for certain very limited purposes.
The trick you can use is to set up a self-join relationship that matches on the Class table:
Then this auto-enter calculation: Max ( YourTable 2::SerialValue ) + 1
Can be used to assign the next serial value to the serialValue field of a new record. Typically, you need to clear both the "Do not evaluate if all referenced fields are empty and the "Do not replace existing value..." check boxes.
If there is the slightest chance that two users might attempt to create new records in your table for the same class at the same time, you should also define a text field wth this auto-enter calculation: Class & SerialValue and set a unique values validation field option on it to guard against the chance that you might get two records with exactly the same combination of class and serial number value.