[RESOLVED] Error in setting Parameter for SubReport?
I'm using CR 11 and have a report in which it has 3 subreports. I'm calling the main report from a VB.Net app. The 3 subreports have 2 parameters each. They also have a Stored Procedure in each of them. lHowever, I'm getting an "Object reference not set to an instance of an object" error on the highlighted line of code. I don't think I've set my parameters up correctly for the subreports. I don't know this for sure because this is the first time I've ever used parameters in a subreport. Any ideas?
Code:
Public Function PrintGroupActivitySummary(ByVal strUserID As String, _
ByVal intGroupID As Integer)
Try
Dim crDoc As New rptGroupActivitySummary
Dim crSub1 As New ReportDocument
Dim crSub2 As New ReportDocument
Dim crSub3 As New ReportDocument
With crConnectionInfo
.ServerName = "HERCULES"
.DatabaseName = "Drip"
.UserID = "CRVBNETSQL"
.Password = "SC1800fuels"
.IntegratedSecurity = True
End With
crSub1 = crDoc.OpenSubreport("IRStatus.rpt")
crSub2 = crDoc.OpenSubreport("Over3Days.rpt")
crSub3 = crDoc.OpenSubreport("OutstandingIR.rpt")
crSub1.SetParameterValue("@userID", strUserID)
crSub1.SetParameterValue("@groupID", intGroupID)
crSub2.SetParameterValue("@userID", strUserID)
crSub2SetParameterValue("@groupID", intGroupID)
crSub3.SetParameterValue("@userID", strUserID)
crSub3.SetParameterValue("@groupID", intGroupID)
PrintGroupActivitySummary = crDoc
Catch ex As Exception
rptErr.clsProcedure = "PrintGroupActivitySummary()"
rptErr.clsMsg = ex.Message
rptErr.WriteToTextFile(ErrorDirectory, "DRIP-ErrorLog.txt")
End Try
End Function
I'm gettin' desparate folks.
Thanks,
Re: Error in setting Parameter for SubReport?
Any ideas? I'm really cuttin' this to the bone...
Re: Error in setting Parameter for SubReport?
You do not have to pass the parameters that many times if they are all the same value. If you go into crystal reports and right click on your sub report you can link the parameters from the main report to the sub report parameter fields.
Re: Error in setting Parameter for SubReport?
Besoup,
The main report does not have any parameters. It's just the 3 subreports that have identical params.
Re: Error in setting Parameter for SubReport?
ok then you can just add parameter fields to the main report and link them to your subs....
Re: Error in setting Parameter for SubReport?
Why do I keep getting prompted in my VB.Net app to enter the paramater values then?
Re: Error in setting Parameter for SubReport?
If you have them linked properly in CR then all you would need is this code:
vb Code:
Public Function PrintGroupActivitySummary(ByVal strUserID As String, _
ByVal intGroupID As Integer)
Try
Dim crDoc As New rptGroupActivitySummary
With crConnectionInfo
.ServerName = "HERCULES"
.DatabaseName = "Drip"
.UserID = "CRVBNETSQL"
.Password = "SC1800fuels"
.IntegratedSecurity = True
End With
crDoc.SetParameterValue("@userID", strUserID)
crDoc.SetParameterValue("@groupID", intGroupID)
PrintGroupActivitySummary = crDoc
Catch ex As Exception
rptErr.clsProcedure = "PrintGroupActivitySummary()"
rptErr.clsMsg = ex.Message
rptErr.WriteToTextFile(ErrorDirectory, "DRIP-ErrorLog.txt")
End Try
End Function
Re: Error in setting Parameter for SubReport?
Using your exact code....I'm still getting prompted 3 times (1 for each subreport) to enter 2 parameter values.
Re: Error in setting Parameter for SubReport?
can you post a screenshot of how one of your links look?
Re: Error in setting Parameter for SubReport?
Here is a screen shot. I am trying to link the subreport to the main report parameters...
Re: Error in setting Parameter for SubReport?
change the bottom selection on the left to ?@groupid without the prefix.
Re: Error in setting Parameter for SubReport?
didn't work....still prompted me as well as the attached Error.
Re: Error in setting Parameter for SubReport?
may seem like a dumb question but did you change them for all 3 sub reports?
Re: Error in setting Parameter for SubReport?
Not a dumb question!!! But yes...I did.
Re: Error in setting Parameter for SubReport?
Somehow, I've resolved it. Don't know exactly what I did except for what Besoup suggested and by updating the SP's.
Re: [RESOLVED] Error in setting Parameter for SubReport?
The same problem is back and I don't know what I did.
Re: [RESOLVED] Error in setting Parameter for SubReport?
How do I reopen this thread?