Am having trouble building a function to loop through a recordset that contains records that can have one or more billing codes under the same patient number. I need to calculate 100% of the highest paying amount, 50% of the second highest and 25% on all remaining amounts. I have a Do While Not rs. EOF but am having trouble building a counter to count through the patient number records and then start over the calculations for the next patient number. Any guidance would be appreciated.