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!

shared variable in subreport and select expert 1

Status
Not open for further replies.

Oona8

Technical User
Apr 3, 2002
25
FR
Hi, I'm using Crystal 8.0, and I have a problem with a shared variable (date format). I'm creating it in a subreport, so that I can get it in the main report. It works fine, though in the main report it doesn't seem to be recognized as a date in the main report, as when I try do do a select expert on it, it shows me another field (from another table) which has a number format..
Is it not possible to use the select expert on a shared variable?
And as a general rule, can I use a shared
variable as a parameter?

Here are my formulas :
Subreport

whileprintingrecords;
shared datevar dateprod;
dateprod := date({table.field})

main report :

shared datevar dateprod;

Thanks for your help!

Oona
 
I can't think of a way to use a shared variable from a sub-report as part of the record selection formula in the main report. If you think about it, it does not make sense. The sub-report is executed only when the relevant part of the main report is processed.

Howard Hammerman,
Crystal Training and Crystal Material
On-site and public classes
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
You might want to redesign your report to do the subreport/mainreport the other way around.

The main report has to do the initial record selection and groups, and the subreport goes off and gets the other stuff you need. Use that as your design criteria.

One potential approach is to use conditional section suppress in the main report based on a shared variable in the subreport. Doesn't really do record selection, but can create the appearance of it. Editor and Publisher of Crystal Clear
 
As chelsea said, you should reverse the subreport and main report. Then use a parameter in the subreport that links to a formula in the main report. This CAN be used for selection, while the shared variable can not. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
I have a main report with three subreports. I would like to prompt for a date in the main report, then shared that to each of the subreports (and select on that date). But you can't use a shared variable in a selection formula.

How can I apply using a parameter in the subreport that links to a formula in the main report?
 
Just link the parm in the main report to the fields in the subreports, you don't need to pass anything, Crystal handles that for you.

-k
 
And the link from the parameter to the subreport field has to be an equal join, correct?

There's no way to say less than or equal to?
 
The "Link" to a subreport is simply a value given to the parameter in the subreport. You can use that parameter however you like in the subreport. Usually it is used in the selection formula where it can be an Equal-To or any other comparison. If you let CR add the parameter for you it will always start out using the comparison "Equal-To" but you can change it. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
I made the less than or equal to changes on the parameter from the subreport link. It's working great. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top