Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting fields in a subreprt

Status
Not open for further replies.

wanzek

Technical User
Mar 8, 2010
58
US
I have a report that has the amount deducted for health insurance in payroll and a subreport with the rates from human resources. Is it possible to highlight the field in the subreport if it doesn't equal the amount in the main report?
 
You would need to pass the amount from the main report to the subreport in a shared variable. In the main report, create a formula:

whileprintingrecords;
shared currencyvar hrrate := {table.hrrate};

Place this in a section of the main report above the one containing the sub, e.g., if the sub is in GHb, place the formula in GHa. Then in the subreport, you can select the corresponding field->format field->borders->color->background->x+2 and enter:

whileprintingrecords;
shared currencyvar hrrate;
if currentfieldvalue <> hrrate then
cryellow else
crnocolor

You should add a reset formula in the main report, in a section after the subreport, e.g., GHc, which can be suppressed:

whileprintingrecords;
shared currencyvar hrrate := 0;

-LB
 
yes,
you would need to create a shared variable to pass the value from the report down into the subreport.

//create variable in main report
Whileprintingrecords;
{@ShareDown]
numbervar shdn;
shdn := {@youramountformula};

//create variable in the subreport
{@ShareInSub}
Whileprintingrecords;
numbervar shdn;
shdn

The shared variable must occur in the main report before the subreport.
 
Ibass,

I tried your formula solution but either I am using it incorrectly or I misunderstood something.

In my main report I used:
whileprintingrecords;
shared currencyvar hrrate := {PRDT.Amount}

In my subreport I used:
whileprintingrecords;
shared currencyvar hrrate;
if currentfieldvalue <> hrrate then
cryellow else
crnocolor

My rate in the main table is field PRDT.Amount and in the subreport it is HRBE.RateAmount.

Thanks
 
In what section did you place the variable in the main report, and in what section is the sub located? Where did you enter the subreport formula?

-LB
 
Variable in main report: Group Footer #3A
Sub located: Group Footer #3b
Subreport formula was entered on the rate field (PRBE.RateAmount) using the format editor > background> x+2 > formula
whileprintingrecords;
shared currencyvar hrrate;
if currentfieldvalue <> hrrate then
cryellow else
crnocolor
 

If you need to send a value to the sub report why not send it as a parameter on the sub report? It seems much more simple than messing with shared variables.
 
I just tested this and it worked perfectly. Does the formula you placed in the main report in GHa show the correct value?

How is the sub linked to the main report? On what field?

TeyBrady has a good suggestion. Just don't use the parameter to link to anything. Then you can reference it in the formatting formula only.

-LB
 
I got the highlighting to work now. Using the shared variable formulas.
I am now trying to get another highlighting value to work. I have 2 different rates. The weekly rate and the monthly rate. The report will be run on both a weekly basis and a monthly basis. I tried doing a datediff shared variable to count the number of days between the beginning payroll date and the ending payroll date. If the datediff is less than 28 don't no color else green. Formula:

whileprintingrecords;
shared currencyvar datediff;
if datediff < 28 then
crnocolor
else

whileprintingrecords;
shared currencyvar hrrate2;
if currentfieldvalue <> hrrate2 then
crgreen else
crnocolor

I must have something wrong in my formula because it doesn't work.
 
Where's the formula where you establish the datediff value? I don't really see what you are trying to do here--still coloring one field and checking the datediff formula for that row?

You should also change it to:

whileprintingrecords;
shared currencyvar datediff;
shared currencyvar hrrate2;
if datediff < 28 then
crnocolor else
if currentfieldvalue <> hrrate2 then
crgreen else
crnocolor

-LB
 
Thank you all for your help. Problem solved!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top