Progress Billing

Does anyone know how to put the Previous Adds & Deductions on a custom report form?  I am using the User Defined line item to show which application it first shows up on.  It works fine if I use it on a detail line of the report, but when I try to use it on a report form I get zero.  For Previous Adds, this is what I tried to use:  [SELECT sum(aialin.chgamt) FROM aialin, aiafrm, aialin INNER JOIN aiafrm on aialin.recnum = aiafrm.recnum WHERE aialin.recnum = {aiafrm.recnum} And aialin.chgamt>0 And aialin.usrdf1<aiafrm.appnum And aialin.linnum Between 1 and 1000]

I think a couple of the fields might be misnamed - I am typing this from memory.  Hopefully you understand what I am asking.  I can get the Total Adds OK, but when I add the user defined field portion it zeroes out.  I am comparing the user defined field to the Application number of the Progress billing.