Topic: Formula field = parent field + subreport field Posted: 11 May 2010 at 12:27pm
Is it possible to create a formula field that sums a parent report field with a subreport field and if so how?
I am doing a payroll report. I do a selection of all transactions that are
wages transactions i.e. transaction type in (list of wages transaction
types) and do this in my main report. In the subreport I do the same
thing for allowances transactions, because I couldn't very well select
these in the same query that I select the wages transactions. The
reason I need to differentiate between them is that social security
contributions are payable on wages and the amount of the contribution
depends on the amount of the wages. Now after taking out the social
security contribution I want to sum the total that is payable to the
employee.
That is why I need to sum the allowances field in the
subreport with the wages - ss contribution field in the main report.
Th
subreport is positioned in the detail column of my main report.
If its not possible to sum the fields in question, is there a better way of achieving my desired result in crystal reports?
Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Posted: 11 May 2010 at 6:25pm
The way to share variables between the main report and the subreport is to create a formula in both the main report and subreport and declare the same shared variable in both formulas. Then they will share their data.
For example, Shared NumberVar TxTotal;
Then in the formulas summarize the data appropriately.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
Thanks Brian. I am new to this therefore it may take me a while to implement your suggestions. I might need some more help to do so. Will get back to you.
And I will definitely purchase a copy of the encyclopedia today.
Create two separate reports WagesReport.rpt which sums up all wages transations for each employee and AllowancesReport.rpt which sums up all allowance transactions for each employee.
I include AllowancesReport as a subreport of WagesReport and place the allowances total in the details section along with the wages total name etc. fields.
My report now looks like the following, which is fine:
Name First Last SSN Bank Account# Wages SS Allowances John Jones1234 Scotia 22-333 230.00 9.00 400.00
I proceeded to add the column GrossPay which is the sum of Wages + Allowances. While editing WagesReport I right click on the Allowance subreport and select the edit subreport option. I then create a new formula field called frmAllowances and in the formula editor I type the following:
{ALLOWANCES.ALLOWANCES} is the field that represents the total allowances.
I save the subreport.
I then edit WagesReport by creating a new formula field called GrossPay which is supposed to sum up the wage amount and allowance amount. In the formula editor I type the following formula for GrossPay:
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum