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!

Passing a variable from a subreport to a main report

Status
Not open for further replies.

Dond12

Technical User
May 3, 2001
57
US
I created a subreport that established a shared date variable; this variable was then passed back to the main report (where I had already declared the same shared variable) and displayed. The problem was that, if I suppressed the subreport, the shared variable disappeared from the main report. Apparently, you can't pass a shared variable from a subreport to a main report if the entire subreport is suppressed.

Since I didn't want the subreport to appear at all, this created a problem for me.

The workaround I came up with was to suppress all of the fields in the subreport except for the formula creating the value I wanted. Then I placed the subreport in the space formerly occupied by the shared variable. This way, there was really no need for a shared variable at all.

The value you see in the main report is really the formula from the subreport's footer. It looks like a field, but it's really an entire subreport with only one field showing.

Is there a better way to do this, or is this the right workaround?
 
Your technique is fine as long as you only need to display the value, not use it in other formulas. If you need to use the value you could use the "Stealth" Subreport technique described in:

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
what you did is fine unless as Ken pointed out you need that number for calculations.

In reality, you chose the simplest solution in the end. Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top