diamondtektips
Programmer
Guys, I'm embarrased b/c I'm at least an intermediate programmer in VB, C++ and other lang but i'm such a lowly novice @ crystal... Your help is greatly GREATLY appreciated.
I have a A/R report which requires a margin calculation per company, and a final total for margin at the end of the report. Here is the code for the "@margin" field per company:
--------------
WhilePrintingRecords;
if {vr_08611.Past03} > 0 then
// if the value in 90 days is greater than 10% of the total
if (Sum ({vr_08611.Past03}, {@GrpCustIDName})) > ((Sum ({vr_08611.NewCur}, {@GrpCustIDName})+Sum ({vr_08611.Past01}, {@GrpCustIDName})+Sum ({vr_08611.Past02}, {@GrpCustIDName})+Sum ({vr_08611.Past03}, {@GrpCustIDName})+Sum ({vr_08611.Over03}, {@GrpCustIDName})) * 0.10) then
// return 0
0
else
// return total - 90 days
((Sum ({vr_08611.NewCur}, {@GrpCustIDName})+Sum ({vr_08611.Past01}, {@GrpCustIDName})+Sum ({vr_08611.Past02}, {@GrpCustIDName})+Sum ({vr_08611.Past03}, {@GrpCustIDName})+Sum ({vr_08611.Over03}, {@GrpCustIDName})) - (Sum ({vr_08611.Past03}, {@GrpCustIDName})))
else
// return 0
0
--------------
i coded it this way b/c i couldn't figure out how to use the built in functions like "sum", etc.
Now, if I use Crystal's Summary feature it tells me it can't create this summary field.
So I inserted a variable definition in the previous header, then tried to add to the variable every time the margin was calculated but i can't figure out how to insert another line into the nested else (Usually in VB you use {} but crystal expects a field if i use {}'s.)
Thus if you can tell me how to build a running total, i.e. how to define a shared var, how to insert summation code into the above nested else, and how to display the doggoned thing... I would be eternally greatful and will mow your lawn...
I have a A/R report which requires a margin calculation per company, and a final total for margin at the end of the report. Here is the code for the "@margin" field per company:
--------------
WhilePrintingRecords;
if {vr_08611.Past03} > 0 then
// if the value in 90 days is greater than 10% of the total
if (Sum ({vr_08611.Past03}, {@GrpCustIDName})) > ((Sum ({vr_08611.NewCur}, {@GrpCustIDName})+Sum ({vr_08611.Past01}, {@GrpCustIDName})+Sum ({vr_08611.Past02}, {@GrpCustIDName})+Sum ({vr_08611.Past03}, {@GrpCustIDName})+Sum ({vr_08611.Over03}, {@GrpCustIDName})) * 0.10) then
// return 0
0
else
// return total - 90 days
((Sum ({vr_08611.NewCur}, {@GrpCustIDName})+Sum ({vr_08611.Past01}, {@GrpCustIDName})+Sum ({vr_08611.Past02}, {@GrpCustIDName})+Sum ({vr_08611.Past03}, {@GrpCustIDName})+Sum ({vr_08611.Over03}, {@GrpCustIDName})) - (Sum ({vr_08611.Past03}, {@GrpCustIDName})))
else
// return 0
0
--------------
i coded it this way b/c i couldn't figure out how to use the built in functions like "sum", etc.
Now, if I use Crystal's Summary feature it tells me it can't create this summary field.
So I inserted a variable definition in the previous header, then tried to add to the variable every time the margin was calculated but i can't figure out how to insert another line into the nested else (Usually in VB you use {} but crystal expects a field if i use {}'s.)
Thus if you can tell me how to build a running total, i.e. how to define a shared var, how to insert summation code into the above nested else, and how to display the doggoned thing... I would be eternally greatful and will mow your lawn...