I've got to keep track of serial numbers in a database and it has to be one record per serial number. But if I want to do an inventory of what serial numbers are in a warehouse, I don't particularly want to run off a list of 10000 serial numbers since that's not very helpful at determinging gaps (lets say bonehead decides to take the middle 50 out and ship them). So in that example I would want to print out a list like this: Code: Serial Number Range Count 00001-04975 4975 05026-10000 4975 So assuming I have 9950 records each with one of those serial numbers, how do I get the data to display something like what I have just presented? The only idea I had was doing a custom function that basically returned the upper limit of consecutive serial numbers for any number provided in a predetermined recordset Function GetUpperLimit(LowerLimit as Long) as Long And then keep checking if the next number belongs in the recordset, returning the last one that does. Or is there a simpler way that I'm just missing?