Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8419

subreport causes report to ask for parameter that has been provided.

$
0
0

Using visual studio 2010 and Crystal reports, I have developed a main report with one subreport.  It looks perfect in the Main Report Preview mode.  The main report uses a date parameter to pull the required information from a sql server database.  I am having problems with the CrystalReportViewer code behind. The code below loads the main page.  The parameter "dJobDate" pulls the information I need for the main part of the report without Parameter Window asking for the @JobDate.

 

******************* No Sub Report

The date is passed when the window opens

Report runs without the Parameter Window appearing

 

Sub frmTrkDispatchRpt_Load(sender AsObject, e As System.EventArgs) HandlesMe.Load

   Dim rpt AsNewTruckDispatchRpt

 

      rpt.SetDataSource(GetData(dJobDate))

   rpt.SetParameterValue("@JobDate", dJobDate)

      crvDispatchReport.ReportSource = rpt

      crvDispatchReport.RefreshReport()


EndSub

 

Here I add a line to load and run the subreport.

 

************ With Sub Report

The date is passed when the window opens

Report will not run with entering a date in the parameter window

 

Sub frmTrkDispatchRpt_Load(sender AsObject, e As System.EventArgs) HandlesMe.Load

   Dim rpt AsNewTruckDispatchRpt

 

      rpt.SetDataSource(GetData(dJobDate))

 

 

     rpt.Subreports("ReqMaterials").SetDataSource("tblReqMaterial")  XXXXX The only line added XXXXX

 

   rpt.SetParameterValue("@JobDate", dJobDate)

      crvDispatchReport.ReportSource = rpt

      crvDispatchReport.RefreshReport()


EndSub

 

When I add the line for the subreport and then run the report I get a Parameter Window asking for the @JobDate.  I have tried rearranging these few lines in various ways without any success.  Just to get an idea of what may be happening i put a Messagebox.Show("HERE") in to see where the program goes.  If the messagebox is before the subreport line, it acts like you would think.  I get the message box, hit enter, and then the Parameters windows opens, asks for the job date, I enter the date and the program runs the report.  If the messagebox is after the subreport line, i get the Parameters window, I enter the job date and the report runs and I never get the messagebox.

 

Any ideas of what I am doing wrong?


Viewing all articles
Browse latest Browse all 8419

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>