Reputation: 1303
Below Is My crystal report structure (shown in Image) ,I am using below formula to get Fee Total
If{DataTableDoctorInfo.Fee_Unit}="Percent" Then
formula = ({DataTableDoctorInfo.Fee}/100)*{DataTable1.Number of Patient}
Else
formula={DataTableDoctorInfo.Fee}*{DataTable1.Number of Patient}* Sum ({DataTableDrmonthlyData.Payable Amount})
End If
now I also want to add sub total In my formula which i am getting In my subreport
from column having sum
of that column values ,Now I want to use this sum in above formula something like this
formula = ({DataTableDoctorInfo.Fee}/100)*{DataTable1.Number of Patient}* {that sum value which I am getting in sub report}
DrMonthlySubRepoPatient
is My sub report shown in image in section 3
,How I can achieve this ?
I tried this code in Main report
formula of FeeTotal
WhilePrintingRecords;
Shared CurrencyVar myTotal;
myTotal :=myTotal;
If{DataTableDoctorInfo.Fee_Unit}="Percent" Then
formula = ({DataTableDoctorInfo.Fee}/100)*{DataTable1.Number of Patient}* myTotal
Else
formula={DataTableDoctorInfo.Fee}*{DataTable1.Number of Patient}* Sum ({DataTableDrmonthlyData.Payable Amount})
End If
and this formula in subreport fo Payble amount field
WhilePrintingRecords;
Shared CurrencyVar myTotal := Sum ({DataTableDrmonthlyData.Payable Amount})
but its giving following error,How do I resolve it?
`The remaining Text does not appear to be part of the formula `
Upvotes: 0
Views: 5788
Reputation: 2750
The formuala in your subreport is missing a semi-colon:
WhilePrintingRecords;
Shared CurrencyVar myTotal := Sum ({DataTableDrmonthlyData.Payable Amount});
EDIT:
After seeing the screenshot, I think your report structure is not very good. Please see the answer to this post on how to structure a report. Another thing that is very important is the placement of your formulas, as well as the possibility of using a linked subreport. Please read this post for more information on how to pass values between reports and subreports. I would leave everything above the black lines in the Page Header. Create a Group 1 and put everything below the black line in that. Base the Group on Number of Patient. Now your subreport needs to "above" your Fee Total formula so that Fee Total can access the value. The syntax of the formula in the subreport should be
WhilePrintingRecords;
Shared CurrencyVar myTotal := Sum ({DataTableDrmonthlyData.Payable Amount});
Then in your main formula you can declare the variable like this
WhilePrintingRecords;
Shared CurrencyVar myTotal := myTotal;
and use it in the rest of the formula.
I think that your problem is the structure of your report.
Upvotes: 1