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!

Null Shared Variables 1

Status
Not open for further replies.
Dec 29, 2007
10
GB
Hi

I’ve come across a very strange problem.

I have a main report that is grouped per contract manager > contract number and shows the summarised amount of actual hours worked on each contract by the engineers. I have inserted within the main report at contract group level and declared a shared variable to pass the planned hours to the main report (i.e. subreport has been placed above the area in the main report I am using the variables.)

The outcome is for the vast majority of the contracts the shared variables are displaying the contract data. However, this is the strange bit, where a contract exists in the main report but doesn’t in the sub report the shared variable returns not 0 but the value of the previous contract which can be found.

E.g.

Contract Planned hrs (Sub Report Variable) ActualHrs
1234567 45 13 471245785 12 11

//Both contract numbers can be found in the sub report - correct

4578998 12 11

//Contract is not found on the sub report so returns the last known contract

4587788 12 11
//Same as above

I have set up the shared variables like this:

Main report:

whileprintingrecords;
shared numbervar pass_hours_inc_sub;
pass_hours_inc_sub;

Sub Report:

whileprintingrecords;
shared numbervar pass_hours_inc_sub:= Sum ({@Hours_Decimal_Inc_Sub}, {Contract_More.CM_Data20})

I’m guessing this is going to be a problem with recognising and knowing what to do with nulls but I have got no idea how to overcome this.

Have you got any ideas, all the help is greatly appreciated!
 
in the subreport, check for nulls, if IsNull .... Set the shared variable to 0 in such a case.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Sorry Madawc could you explain this in more detail. Do you mean right click subreport and select format sub report?
 
You need a reset formula like:

whileprintingrecords;
shared numbervar pass_hours_inc_sub := 0;

You would place this in a section immediately before the one containing the subreport section_a if the sub is in section_b or in a section right after it executes. It would help if you specified the report section the sub is in.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top