Hi
I am just having a small problem with the MAX function. I am trying add a uninque ID to a record by taking the MAX value of all records that meet a particular criterial and adding 1 onto it. Basically I need my unique ID to be concurrent for each person submitting new data into the system.
For Example John has 10 records, his next will be 11
Mary has 3 records, her next record will be four
(Im dont mean to sound patronising but I cant think of another way of explaining it)
My criteria is defined by the persons login name which is copied into every record when its created so it is possible to count:
If Temp IS NEW Temp.AgencyCode = LoggedInAgency.LoginName
My Code to generate the unique ID is as follows
If Temp IS NEW Then
Temp.indexAgency=MAX Temp.indexAgency WHERE (Temp.AgencyCode=LoggedInAgency.LoginName)+ 1
My problem is that the new records keep missing one everytime a record is created, for example two records created one after the other have a Temp.indexAgency value of 1 then 3 (wheres 2)
I am sorry to be a pain but I had to ask because its only a small piece of code and I have been staring at it for hours - can you see anything wrong with it? If I dont put the +1 on the end my records repeat the same value very odd?
I hope that all makes sense
Best Regards
John