Rolling number field that resets to 0 after it reaches 99,999

Hi. I am trying to use knack to generate unique lot numbers. The lot number is a concatenation of location number, last digit of the year, dept number and 5 digit number that increments by 1 from 0 to 99,999 then starts back at 0 (ex. 900 9 2 00001). I have everything working using text formulas except for the last 5 digits. In Access or Excel, I would look at the previous number and create and if statement that would be something like IF(Previous<99999, Current = Previous +1, 0).

Any ideas on how can I accomplish the same thing in Knack?

{Current Number}<{Reset Threshold}? {Current Number}+1 : 1