Set parameter values in subreport from VB6 / Crystal XI

I have an existing Crystal Reports XI  report but have recently added an *unlinked* subreport.  I have the subreport working through Crystal's IDE, but now I need to integrate it into my VB6 app.  

The datasource for the subreport is a SQL 2000 stored procedure with 5 input parameters.  

The main report has a different datasource, and I successfully am passing the parameter values to it.  Again, the main report is not linked to the subreport.  

The issue is that I don't know how to pass values to the subreport through the VB code.

Who is Participating?
mlmccConnect With a Mentor Commented:
Check this out. It is for CR 9 but the RDC hasn't changed much

frodomanConnect With a Mentor Commented:
If that doesn't work, you can always add the parameters to your main report and link them to the subreport.  There's no rule that says the parameters have to be used in your main report for anything, then can exist there only to simplify passing to a subreport.

It's not that you can't pass params to a subreport - you can - but it may be easier to just add them to you main report in some cases.

casatoneAuthor Commented:
mlmcc, I tried using the sample you posted & think it got me closer, though I keep getting prompted for the subreport's parameter values (as Crystal does from within its designer).
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

casatoneAuthor Commented:
frodoman can you explain how to go about that or post a sample?  Unfortunately I don't know how to do that.
casatoneAuthor Commented:
I also tried this approach set the parameters:  

        gReport.ParameterFields.GetItemByName("@StopDate_From", "Subreport1").AddCurrentValue mStopDate_From

"gReport" is an object variable that refers to the main report.  I figured since the subreport ("Subreport1") is named in the main report, perhaps I could get the values passed that way.  

Unfortunately, this approach results in the following error message:

Run-time error '-2147189553 (80047ccf)':  The value or range you are adding has already existed.

In the Field Explorer, simply add the parameters you need in your main report.  Then rt-click on the subreport and select "change links".  Click on the parameter in your main report and select it, then select the parameter from the dropdown for your subreport.

Now you can pass these parameters directly to your main report and they'll be passed through to the subreport.  
casatoneAuthor Commented:
Got it working.  I kept trying different approaches, but ultimately found a way that was based generally off of mlmcc's link with a sample...really needed a sample to get my brain around this.  So, I split the points to be fair because I think you both (mlmcc & frodoman) helped guide me there.  Thanks very much.
Glad i could help

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.