Numbering a collection at every change of a user

Hi,

I made a bit of a boo boo. I have a web form that looks at a view to create the latest claim number. (using the following code in the Claim_Num field)

Temp := @DbLookup(“Notes” : “NoCache” ; @Subset(@DbName; 1) : “Claims.nsf”; “(Claim Number)”; @UpperCase(UserName); 1);

FIELD Claim_Num := Claim_Num;

@If(@IsError(Temp); @SetField(“Claim_Num”; 1); @SetField(“Claim_Num”; @Elements(Temp) + 1))

However I archived some (not all) of these documents and now when users make a new claim the code above starts the numbering process at a lower number. (because i removed some records)

To fix this issue and any claims that come in the meantime. I am looking for an agent that i can run across the whole collection and set a claim number based off every user.

So if user JOHN SMITH has 10 claims i want his claims to be re-numbered 1 thru 10. While User JACK SPRAT has 5 claims and I need his claims numbered from 1 thru 5 with the latest claim showing the higher number.

So essentially i need some script or formula that will look at the entries in a collection and at every change in USERNAME set the CLAIM_NUM field with a numerical count on the form.

ANother way to say it is if i select a group of records from a view, I need an agent to number JACK SPRATS records 1, 2, 3, 4, 5

I want to run this from an agent in a view

Please help!

thanks in advance…

Dave