>I will explain in words since I have a problem creating a sample SQL Select.
>Say, I have TableA (structure as of example in my initial message).
>Say, I have a TableB (a little different structure than TableA but very similar, for the purpose of this example).
>I want to process records in TableA and, for each record in TableA, add a record in TableB. As I process I want to Count the total of field Quantity and when the total value of processed records Quantity field is greater or equal to some variable value, stop adding records to TableB.
>And as I process records in TableA and adding records to TableB, I want to process "older" records First and then newer. So if the Total Quantity value (paragraph above) hits the "limit", the newer records of TableA are not processed.
>
>Does it make any sense? :)
Yup - I sort of figured that you were trying to do a cumulative sum.
As I type, I'm sure Naomi is typing up a code sample because I know there have been discussions on this topic many times. But if she doesn't have time to post one, I will.