Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Subreport issue! Post Reply Post New Topic
Author Message
mutekinahito
Newbie
Newbie
Avatar

Joined: 20 Feb 2008
Location: Argentina
Online Status: Offline
Posts: 2
Quote mutekinahito Replybullet Topic: Subreport issue!
     Posted: 21 Feb 2008 at 3:08am
Hi everybody,
 
Help! Help! I had to create about a dozen reports for an vb.net app. I used CR2008 DE for this and I am able to pass all the required parameters and load all of these reports, but one. This repots is the only one that has an embeded subreport that summarizes data using as a paramenter a field from the main report (RegionID). Since the repot and it subreports(one per region based on main report's data) loads nice an neat in the CR2008 DE I think everything is properly set up.
 
When I call thie reports from the vb.net2002 app, the main report load, but the subreports don't. I have followed CR instructions on how to pass the tables logoninfo to the subreport, but still no data is loaded.
 
Would it help if I post the code I's using in here? Well, hope anyone can help. Thanks a lot in advance for your time and interest.
 
Alex.
 
P.D. I am posting in here because I have not been able to find any vb.net forum with clues about this.
minna-san domo arigatou gozaimasu
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 21 Feb 2008 at 6:11am
Yes, please post the code that you're using.   If you use the code tag (look under the "Forum Codes" link below if you're not familiar with it from other forums) your code will retain its formatting and be easier to read.
 
-Dell
IP IP Logged
mutekinahito
Newbie
Newbie
Avatar

Joined: 20 Feb 2008
Location: Argentina
Online Status: Offline
Posts: 2
Quote mutekinahito Replybullet Posted: 21 Feb 2008 at 9:03am
Hi Hilfy,
 
Thanks for your interest. Here is the code I am using.
 

  Private Sub Set_LogonInfo(ByRef Report As ReportDocument)
        Dim crTable As Table
        Dim crTables As Tables
        Dim crDatabase As Database
        Dim ConInfo As New ConnectionInfo()
        Dim crTableLogOnInfo As TableLogOnInfo
        
       
With ConInfo
            .ServerName = "DBServer" : .DatabaseName = "Betloader®"
            .UserID = "sa" : .Password = "masaka"
        End With

        crDatabase = Report.Database
        crTables = crDatabase.Tables
        For Each crTable In crTables
            crTableLogOnInfo = crTable.LogOnInfo
            crTableLogOnInfo.ConnectionInfo = ConInfo
            crTable.ApplyLogOnInfo(crTableLogOnInfo)
        Next

        'to handle logoninfo for subreport
        Dim crSections As Sections
        Dim crSection As Section
        Dim crReportObjects As ReportObjects
        Dim crReportObject As ReportObject
        Dim crSubreportObject As SubreportObject
        Dim crSubreportDocument As ReportDocument

        'adds logoninfo to subreport when exists
        crSections = Report.ReportDefinition.Sections

        For Each crSection In crSections
            crReportObjects = crSection.ReportObjects
            For Each crReportObject In crReportObjects
                If crReportObject.Kind = ReportObjectKind.SubreportObject Then
                    crSubreportObject = CType(crReportObject, SubreportObject)
                    crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
                    crDatabase = crSubreportDocument.Database
                    crTables = crDatabase.Tables
                    For Each crTable In crTables
                        crTableLogOnInfo = crTable.LogOnInfo
                        crTableLogOnInfo.ConnectionInfo = ConInfo
                        crTable.ApplyLogOnInfo(crTableLogOnInfo)
                    Next
                End If
            Next
        Next
 End Sub

   Private Sub Set_Params(ByVal Key As Short, ByRef Params() As String, ByRef Report As ReportDocument)
        Dim ParamVals As ParameterValues
        Dim ParamDisVal As ParameterDiscreteValue
        Dim ParamField As ParameterFieldDefinition
        Dim ParamFields As ParameterFieldDefinitions

        Try
            ParamFields = Report.DataDefinition.ParameterFields
            Select Case Key
                Case 0
                    ParamField = ParamFields.Item("@EOWDate") : ParamVals = ParamField.CurrentValues
                    ParamDisVal = New ParameterDiscreteValue() : ParamDisVal.Value = Params(0)
                    ParamVals.Add(ParamDisVal) : ParamField.ApplyCurrentValues(ParamVals)
                    'the subreport uses two paramaters. It is linked to the main report's @EOWDate
                    'and one of its fields "Region_Id"
                ......
            End Select
        Catch
            Handle_Er(Err, "Set_Params")
        End Try
    End Sub

  Private Sub RepMnu_Click(ByVal sender As Object, ByVal e As EventArgs) Handles MnuFig.Click, MnuLog.Click, MnuActiv.Click
        Dim iKey As Short
        Dim Frm As FrmParams
        Dim iParams(3) As String
        Dim SubReport As New ReportDocument()

        Try
            iKey = GetRepKeys(sender) 'Sets an internal indicator based on the sender
            If iKey = -1 Then
                Msg("An invalid selection was made!" & Chr(10) & "Please, try again.", 48, Text)
            Else
                Frm = New FrmParams(iKey) : Frm.ShowDialog() 'with this form the user selects the required param values
                If Frm.RunReport = True Then
                    Cursor = Cursors.WaitCursor
                    iParams = Frm.iParams
                    Set_Document(iKey, Report)  'obtains the report's path
                    Set_LogonInfo(Report)  
                    Set_Params(iKey, iParams, Report)
                    RepView.ReportSource = Report
                Else
                    Msg("The report was canceled by the user!", 48, Text)
                End If
            End If
        Catch
            Handle_Er(Err, "RepMnu_Click")
        Finally
            Cursor = Cursors.Default
        End Try
 End Sub

 



Edited by mutekinahito - 21 Feb 2008 at 9:06am
minna-san domo arigatou gozaimasu
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum