Results 1 to 17 of 17

Thread: [RESOLVED] Error in setting Parameter for SubReport?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [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,
    Last edited by blakemckenna; May 29th, 2008 at 12:33 PM.
    Blake

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Error in setting Parameter for SubReport?

    Any ideas? I'm really cuttin' this to the bone...
    Blake

  3. #3
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    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.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  5. #5
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    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....

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Error in setting Parameter for SubReport?

    Why do I keep getting prompted in my VB.Net app to enter the paramater values then?
    Blake

  7. #7
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    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:
    1. Public Function PrintGroupActivitySummary(ByVal strUserID As String, _
    2.                                               ByVal intGroupID As Integer)
    3.         Try
    4.             Dim crDoc As New rptGroupActivitySummary
    5.  
    6.  
    7.             With crConnectionInfo
    8.                 .ServerName = "HERCULES"
    9.                 .DatabaseName = "Drip"
    10.                 .UserID = "CRVBNETSQL"
    11.                 .Password = "SC1800fuels"
    12.                 .IntegratedSecurity = True
    13.             End With
    14.  
    15.             crDoc.SetParameterValue("@userID", strUserID)
    16.             crDoc.SetParameterValue("@groupID", intGroupID)
    17.  
    18.  
    19.             PrintGroupActivitySummary = crDoc
    20.  
    21.         Catch ex As Exception
    22.             rptErr.clsProcedure = "PrintGroupActivitySummary()"
    23.             rptErr.clsMsg = ex.Message
    24.             rptErr.WriteToTextFile(ErrorDirectory, "DRIP-ErrorLog.txt")
    25.         End Try
    26.     End Function

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  9. #9
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Error in setting Parameter for SubReport?

    can you post a screenshot of how one of your links look?

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Error in setting Parameter for SubReport?

    Here is a screen shot. I am trying to link the subreport to the main report parameters...
    Blake

  11. #11
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Error in setting Parameter for SubReport?

    change the bottom selection on the left to ?@groupid without the prefix.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Error in setting Parameter for SubReport?

    didn't work....still prompted me as well as the attached Error.
    Blake

  13. #13
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: Error in setting Parameter for SubReport?

    may seem like a dumb question but did you change them for all 3 sub reports?

  14. #14

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Error in setting Parameter for SubReport?

    Not a dumb question!!! But yes...I did.
    Blake

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: [RESOLVED] Error in setting Parameter for SubReport?

    The same problem is back and I don't know what I did.
    Blake

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: [RESOLVED] Error in setting Parameter for SubReport?

    How do I reopen this thread?
    Blake

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width