Hello,
I have an application vb.net Vs2005 winform an Crystal Report for .NET.
I have a report whith 3 subreports : i want to specify RecordSelectionFormula for the 3 subreport but it work only for one (the last have set) :
Part of my code :
Dim dob_Report As New CrystalDecisions.CrystalReports.Engine.ReportDocument
dob_Report.SetDatabaseLogon("SYSTEM", "pass@123", "CP", "DB_LIVE")
Dim Tables As CrystalDecisions.CrystalReports.Engine.Tables = dob_Report.Database.Tables
Dim table As CrystalDecisions.CrystalReports.Engine.Table
For Each table In Tables
table.LogOnInfo.ConnectionInfo.ServerName = "CP"
table.LogOnInfo.ConnectionInfo.DatabaseName = "DB_LIVE"
table.LogOnInfo.ConnectionInfo.UserID = "SYSTEM"
table.LogOnInfo.ConnectionInfo.Password = "pass@123"
table.ApplyLogOnInfo(table.LogOnInfo)
table.LogOnInfo.ConnectionInfo.AllowCustomConnection = True
table.Location = "DB_LIVE." & Mid(table.Location, InStrRev(table.Location, ".", Len(table.Location)) + 1)
Next
Dim osubrpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
For i As Integer = 0 To dob_Report.Subreports.Count - 1
osubrpt = dob_Report.Subreports.Item(i)
Dim subrpt_Tables As CrystalDecisions.CrystalReports.Engine.Tables = osubrpt.Database.Tables
For Each table In subrpt_Tables
table.LogOnInfo.ConnectionInfo.ServerName = "CP"
table.LogOnInfo.ConnectionInfo.UserID = "SYSTEM"
table.LogOnInfo.ConnectionInfo.Password = "pass@123"
table.LogOnInfo.ConnectionInfo.DatabaseName = "DB_LIVE"
table.ApplyLogOnInfo(table.LogOnInfo)
table.LogOnInfo.ConnectionInfo.AllowCustomConnection = True
table.Location = "DB_LIVE." & Mid(table.Location, InStrRev(table.Location, ".", Len(table.Location)) + 1)
'table.ApplyLogOnInfo(table.LogOnInfo)
Next
osubrpt.VerifyDatabase()
Next
dob_Report.VerifyDatabase()
'... I passed the code that set log info on the table of report and subreport
dob_Report.OpenSubreport("Summary").RecordSelectionFormula = "{a.DOCDATE} >= date(" & strFromDate & ") " & " AND " & "{a.DOCDATE} <= date(" & strToDate & ")" & " AND " & "{a.LOCATIONCODE} = '" & strLocation & "'" & " and " & "{a.DOCTYPE} = '" & "I" & "'" & stroption
dob_Report.RecordSelectionFormula = "{s.DOCDATE} >= date(" & strFromDate & ") " & " AND " & "{s.DOCDATE} <= date(" & strToDate & ")" & " AND " & "{s.LOCATIONCODE} = '" & strLocation & "'" & " and " & "{s.DOCTYPE} = '" & "I" & "'" & " and " & "{s.ex} <> '" & "exp" & "'" & stroption
'Now i want to set RecordSelectionFormula for subreport
form1.crystalreportviewer1.ReportSource = dob_Report
form1.Text = strFormTitle
form1.ShowDialog()
when i do that
first and second subreport don't apply the RecordSelectionFormula and show all data
third subreport is displaying proper.
I've tried dob_Report.OpenSubreport(0) this method also but results are same.
Environment:
Visual Studio 2005, Crystal Report 10, SAP HANA Studio, SAP 9.0