Link to home
Start Free TrialLog in
Avatar of casatone
casatoneFlag for United States of America

asked on

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.

ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of casatone

ASKER

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).
frodoman can you explain how to go about that or post a sample?  Unfortunately I don't know how to do that.
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.  
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.
Avatar of Mike McCracken
Mike McCracken

Glad i could help

mlmcc