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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Variable - Main to Subreport

Status
Not open for further replies.

Rustywheel

Technical User
Oct 13, 2011
2
US
Apologies, it seems to be a fairly common topic on this board....but I think my dilemma is a bit different...passing the value from the section in the main report to the subreport.

In main report GF3

Whileprintingrecords;

Shared numbervar insallo = Sum ({PatientVisitProcsAgg.OrigInsAllocation}, {PatientVisit.PatientVisitId});

Sum ({PatientVisitProcsAgg.OrigInsAllocation}, {PatientVisit.PatientVisitId})

'this replicates the group sum and creates the shared variable'



in the subreport (which is in GF3A of the main report)

Shared numbervar insallo;

'what I hope to pull through is the value from the number above. Yet all that returns are $0.00"

'Additionally, I'm in group 3 within the subreport - not sure that's relevant. Other links to the section above seem to match'

Thoughts?

-Neil



 
Rustywheel,

Shared Variables in Crystal reports are executed as one would read plain English text - the variable must execute in a section "above" the section which you intend to use it.

Is group 3 based on: {PatientVisit.PatientVisitId}? (I would assume it is)

Perhaps it is simply a syntax error, as I noticed a character missing from your first formula. To rule this out, please setup your formula field in GF3 as:
Code:
Whileprintingrecords;
Shared NumberVar insallo [red][b]:[/b][/red]= Sum({PatientVisitProcsAgg.OrigInsAllocation}, {PatientVisit.PatientVisitId});

Please advise as to your findings.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Rustywheel,

In addition to my above post, the formula in your Subreport should be as follows:

Code:
WhilePrintingRecords;
Shared numbervar insallo;

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Mike,

Many thanks for your help! Nice catch with the minutia of the syntax - definately a factor there.

However, the biggest issue was the fact that the field I was working with is set up as a currency value, and not a numeric


changed the dim statement to "Shared Currencyvar Insallo;" and it's good to go!

 
Rustywheel,

Interesting that the field type required that change, I haven't come across that before. Though, now that I think about it, I think the "Currency" fields in my Primary DB are actually of type "Double", and I format as currency on reports...

Thanks for the update, good to know the variable types are that stringent.

Cheers! [smile]

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top