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

Parameter ALL passed to subreport 1

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hello

I use CR9 on a Windows XP computer connecting to an Access XP database via ODBC DSN.

I have two issues to request assistance on with regards to passing parameters to a subreport.

The first issue involves the use of a parameter where one of the entries is ALL. For example, I have a parameter called Programs that includes ALL so that the main report selection would be ({?ProgramParam} = "ALL" or {Programs} = {?ProgramParam}). I know that when linking another field (without ALL) from subreport to main report the record selection formula would be {Programs} = (?Pm-?ProgramParam) but how to include if the user selects "ALL"?

The second question involves passing a boolean parameter to a subreport. For instance I have the parameter fields of ?CMG and ?MRP in parameter group 2 and a formula for the data element indicating:

If {?CMG} then {@CMGName) else
If (?MRP} then (@MRPName)

Again, the same header and formula is in the subreport so how can I pass this parameter or is it even possible?

All assistance greatly appreciated!

Shelby

 
Hi

I was sure I had tried this syntax previously but anyway I got the "ALL" parameter to pass by adding to the selection criteria in the subreport so it read:

{@DisDate} = {?Pm-?DischargeDate}
and
({?Pm-?Program} = "ALL" or {@Programs} = {?Pm-?Program})

Now I just need to know how to pass the boolean parameter values - thanks!

Shelby
 
Hey Shelby,

The first one is easy - rather than trying to match your parameter in the main report with a field in the subreport - try creating a parameter in the subreport first - identical to the one in the main report - therefore - it will be expecting the "ALL" - then change the record selection in the subreport accordingly.

The second one - rather than trying to pass data to the subreport via a parameter - do it using a shared variable (see help file - but both the main and subreport can access/change/reset a shared variable)

I hope this helps.

Cheers,

paulmarr
 
Hi paulmarr

Thanks very much but what help file are you referring to?

Shelby
 
Hi Shelby,

The Crystal Help File and I quote:
"Shared variables (Basic syntax)
Shared variables use the same memory block to store the value of a variable throughout the main report and all of its subreports. Thus shared variables are even more general than global variables. To use a shared variable, declare it in a formula in the main report as in the following example:

Shared x As Number
x = 1000

and declare it in a formula in the subreport as in the following example:

Shared x as Number

To use shared variables, the variable must be declared and assigned a value before it can be passed between the main report and the subreport.

I hope this explains things!

paulmarr
 
Hi paulmarr

As I'm sure you've already determined, I'm not very familiar with variables, shared or otherewise!

I'll explain further the report because I'm not sure how to execute your idea:

I have 2 Group levels in the report. For GroupA the formula is:

If {?CMG} then {@CMGName) else
If (?MRP} then (@MRPName)

so I need to be able to pass that value to the subreport. But I can't actually use the variable as the Group value because it is non-recurring - or have I done it wrong?

I really appreciate your help!
 
No worries,

Formula in main report:

shared stringvar variablepass := "";

If {?CMG} then variablepass := {@CMGName) else
If (?MRP} then variablepass := {@MRPName)


********************************
Formula on subreport

shared stringvar variablepass;

and then group on it or do whatever you are doing with it - you didn't say.

I hope this helps

paulmarr
 
Hi paulmarr

I can't seem to get this to work though I am learning a lot about variables so thanks!

Anyway just to test the issue of variables before including the parameters etc. I just created a variable in the main report:

shared stringvar element := "";
element := "All Sites";

Then in the subreport, I created a field to place in the header with the formula of:

shared stringvar element;

But it's not passing to the subreport. Also, you indicated that I would be able to group on this field which is what I wish to do but when I created the report as you instructed, it doesn't show up in the list for me to group on. What am I doing wrong?

Shelby

 
Shelby,

The placement is important - the formula must reside in the main report in a section above the section where the subreport resides.

If it is below the formula would not have executed yet.

It all depends on how often the subreport is fired off as to where I would initially declare the varible.

I always experiment with "silly" data until I can figure it out and then apply it to the production report.

Hope this helps!

paulmarr
 
Ta Da - placement was the issue (which makes sense now but I didn't think of it before!)

I love it when you learn something new and think of the multitude of ways it can be applied to other reports and future development. The concept you have just taught me will certainly do that - thanks so much!!

Shelby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top