I have a query result that sorts records from table "A" by individual value and category. I want to loop through the recordset and assign each record successively into one of "n" groups until all records are assigned. Assignment to a group would be made by updating a field in the query's source table (A) with a group number. The number of groups is variable, depending on the number of records in a second table called "TRanges".
record 1 assigned to group 1
record 2 to group 2
record 3 to group 3
record 4 to group 1
record 5 to group 2 ... and so on.
In the end, I want to have a fairly even distribution of categories in each group, and each group's total value will be successively greater (which is why I sorted the records as I did with the query). There is no guarantee that the data will contain even categories, so the outcome of category distribution doesn't have to be statistially exact, but close enough.
I'm a bit wrapped around the axle on the code. I can do the Do While looping through the DAO recordset, but I'm having trouble managing the variables.