Click to See Complete Forum and Search --> : RecordSelectionFormula for both crystal report and sub report...


foody
November 5th, 2007, 02:14 PM
Hello,


I am developing using VB.NET and I have a major problem with my crystal report. When I want to attempt to display information on the crystal report with a condition that UserID = <Value> and ReportID = <Value> using RecordSelectionFormula for both the main report and it's subreport I get the following problem:

Main report displays ALL values and sub report displays the correct value, or sometimes it is the other way around depending on how I adjust the code but it is neither both. How can I fix this problem?

Below is the code:

Public Sub BindReportDetailsData(ByVal UserID As String, ByVal ReportID As Long, ByVal _Path As String, ByVal _ReportViewer As CrystalDecisions.Web.CrystalReportViewer)
Dim _Report As New ReportDocument
Dim _MySubReport As New ReportDocument
Dim _MyReport As ReportObject = Nothing
Dim _SubReportObject As SubreportObject = Nothing



_Report.Load(_Path)
_Report.SetDatabaseLogon("foody", "amiga1200")

For Each _MyReport In _Report.ReportDefinition.ReportObjects
If _MyReport.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
_Report.DataDefinition.RecordSelectionFormula = "{ExpenseUsers.UserID}= ""{" & UserID & "} AND {ExpenseItems.ReportID} = " & ReportID & ""
_SubReportObject = CType(_MyReport, CrystalDecisions.CrystalReports.Engine.SubreportObject)
_MySubReport = _SubReportObject.OpenSubreport(_SubReportObject.SubreportName)
_MySubReport.DataDefinition.RecordSelectionFormula = "{ExpenseUsers.UserID}= ""{" & UserID & "} AND {ExpenseItems.ReportID} = " & ReportID & ""
_ReportViewer.DisplayToolbar = True
_ReportViewer.HasRefreshButton = False
_ReportViewer.HasSearchButton = False
_ReportViewer.HasToggleGroupTreeButton = False
_ReportViewer.HasViewList = False
_ReportViewer.HasZoomFactorList = False
_ReportViewer.HasPageNavigationButtons = False
_ReportViewer.HasGotoPageButton = False
_ReportViewer.HasDrillUpButton = False
_ReportViewer.HasCrystalLogo = False
_ReportViewer.HasPrintButton = True
_ReportViewer.ReportSource = _Report
End If
Next

'_Report.Subreports.Item(0).DataDefinition.RecordSelectionFormula = "{ExpenseItems.ReportID}=" & _ReportID & ""


_ReportViewer.DataBind()
End Sub

Can someone help me please? Thanks in advance.

foody
November 9th, 2007, 11:43 AM
Please can anyone help me in this regard?

foody
November 12th, 2007, 10:11 AM
Can someone please help me?! Thanks in advance.