Pass Parameters to subreport vb ocx

I have a report with a sub report in it. I have a parameter field in each that handles a date range in that sub report. How do I pass said date range from VB to that sub report? I would guess

    q = Format(dtFrom.Value, "yyyy-mm-dd") & " 00:00:00.000"
    r = Format(dtFrom.Value, "yyyy-mm-dd") & " 00:00:00.000"
    strParm = "date(mgmtprod.rpt); " & q & "," & r & "; TRUE"
    CR.ParameterFields(1) = strParm 'set the parm
    CR.Action = 1

Where dtFrom and dtTo are drop down boxes with dates in them. and date is the paramter name and mgmtprod.rpt is the sub report. When I run this I get invaild parameter name.
LVL 2
t1clausenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RainMan82Commented:
       Dim param1Fileds As New CrystalDecisions.Shared.ParameterFields
        Dim param1Field As New CrystalDecisions.Shared.ParameterField
        Dim param1Range As New CrystalDecisions.Shared.ParameterDiscreteValue

        param1Field.ParameterFieldName = "paraName"                   ' Parameter Name In Crystal Report
        param1Range.Value = Request.QueryString("parameter1")         ' value For Parameter Field
        param1Field.CurrentValues.Add(param1Range)
        param1Fileds.Add(param1Field)                                 ' To add parameter in parameterslist
        CrystalReportViewer1.ParameterFieldInfo = param1Fileds        'to pass parameters to report viewer
        CrystalReportViewer1.ReportSource = Request.QueryString("Path") ' Assign Report Source to the viewer
        CrystalReportViewer1.Visible = True
0
t1clausenAuthor Commented:
This uses the viewer. I need to use the OCX control. Does this even go for the sub reports?

I tried getting around it by creating a parameter feild in the main report and linking it to the parameter feild in the subreport but that doesn't work either.
0
frodomanCommented:
I believe you have to pass the parameter to the main report.  For example if you have 2 parameters in the main report and 1 in the subreport then to pass the subreport parameter you would pass:

CR.ParameterFields(3) = strParm  (1 & 2 go to the main report).

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
t1clausenAuthor Commented:
I think I need to go back to the drawing board and see if I can create a SQL veiw that will get me around createing sub reports. Thanks for the help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.