Gotcha. Well, I'm going to write this off the top of my head so you will have to tweak/debug it. If you understand the general idea then you should be able to work it out...
First off, you need to group by Item. This will let you put formulas in the group header and footer.
Next you need a formula which declares the global variables and zeros them out. Something like
Global NumberVar m1:=0;
Global NumberVar m2:=0;
etc.
Put this formula in the Group Header. Now, every time a new item is ready to print, all the variable will be reset.
Now for the tricky part. You need to store the historical data for each month in the appropriate variable. I would do this by finding out how many months are between the today and the current record's month. Then use the result to store to figure out which variable to store the value in.
Global NumberVar m1;
Global NumberVar m2;
....
NumberVar NumMonths;
NumMonths = DateDiff(CurrentDate, {yourtable.yourtransactionfield}, "M");
Select NumMonths
Case 0:
m1 := {yourtable.yourinventoryonhand}
Case 1:
m2 := {yourtable.yourinventoryonhand}
....
Case 15:
m16 = {yourtable.yourinventoryonhand};;
Put this in the Details section. Everytime a record is ready is going to print, the appropriate variable will be populated.
You also need to Suppress the Details section because you don't want to see all that data as it's being calculated.
Once you get to the group footer, all the variables will have their data popluated. So create a formula that simply outputs each variable. One formula per variable.
Global NumberVar m1;
m1;
Global NumberVar m2;
m2;
etc.
Put each one of these formulas in the Group Footer. When the report runs, the Details section will do the work of calculating where the on hand numbers belong and the group footer will display them.
Give that a whirl and see what you come up with!
Brian