Consider a self-relationship between RI, based on your x,y,z field (and date? didn't understand that part), sorted by number. Sorted descending, the first number you get via that relationship is the last one used (or sort ascending and use Last() ). Then add an auto-enter calculation à la
Case ( type = "x" or type = "y" or type "z" ; RI_selfJoin::number + 1 ; type = "A" or type = "b" ; "Your a/b Message" )
unless the field can only be x, y, z, a or b – then the second test is unnecessary, and you can make its result the default result.
If an initially a/b field should recive a number after switching the type to x/y/z, you need to uncheck the “Do not replace existing value…” checkbox for auto-enter calc.
I actually remember a similar thread from not too long ago, but cannot find it at the moment … (but I'm sure I made the same suggestion …)
With a couple of variations this worked out well.
I setup a couple of value lists with the values of the two different types. Then a couple of auto enter fields with a value of 1 if it was in one of the relevant value lists. Then a count summary field for each of those auto enters.
Then the suggested self join back to the RI table, along with a relationship to the Previous sections allowed me to setup auto consecutive numbering across sections when looking at the RI's via sections. Duplicating those relationships for the Table Occurance of RI_ByDay (with some slight modifications in logic) allowed similar auto consectuive numbering across the whole day.