I have created a report under VB.NET using the Crystal objects that ship with .NET. The report accepts date parameters and works fine with the following exception. When using parameters, I get back a complete record set (in this case 18 records) but can only navigate to the 1st, 2nd, and last pages using the toolbar. However I can enter any page between the range of 1-18 in the "GoTo" box in the toolbar and navigate to that page successfully.
If I eliminate the parameters and hard-code the desired date range I get a report back that I can successfully navigate through the pages consecutively.
Has anyone else experienced this? I'm brand new to VB.NET and CR and I'm sure it's just my inexperience with these technologies that's causing me to overlook something simple. Any help would be greatly appreciated.
My code is shown below for convenience.
Thanks,
D. Porter
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Public Class DiscreteParmsEx
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
Protected WithEvents btnRefresh As System.Web.UI.WebControls.Button
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents lblStartDate As System.Web.UI.WebControls.Label
Protected WithEvents txtStartDate As System.Web.UI.WebControls.TextBox
Protected WithEvents lblEndDate As System.Web.UI.WebControls.Label
Protected WithEvents txtEndDate As System.Web.UI.WebControls.TextBox
Protected WithEvents btnStartDate As System.Web.UI.WebControls.Button
Protected WithEvents btnEndDate As System.Web.UI.WebControls.Button
Protected WithEvents LastPage_Button As System.Web.UI.WebControls.Button
Protected WithEvents Forward_Button As System.Web.UI.WebControls.Button
Protected WithEvents Back_Button As System.Web.UI.WebControls.Button
Protected WithEvents FirstPage_Button As System.Web.UI.WebControls.Button
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnExport As System.Web.UI.WebControls.Button
''CR Variables
Dim crReportDocument As OrderDetail
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterRangeValue As ParameterRangeValue
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
''Create an instance of the strongly-typed report object
crReportDocument = New OrderDetail()
''The viewer's reportsource must be set to a report before any
''parameter fields can be accessed.
CrystalReportViewer1.ReportSource = crReportDocument
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
''Get the collection of parameters from the report
crParameterFields = CrystalReportViewer1.ParameterFieldInfo
''Access the individual parameter field "Order Date Range"
crParameterField = crParameterFields.Item("Order Date Range"
'''Cast the variable to hold the values to pass to the viewer before execution
crParameterValues = crParameterField.CurrentValues
crParameterRangeValue = New ParameterRangeValue()
Dim myStartDate As DateTime
Dim myEndDate As DateTime
If txtStartDate.Text <> "" Then
myStartDate = txtStartDate.Text
Else
txtStartDate.Text = "2/18/1996 12:00:00AM"
myStartDate = txtStartDate.Text
crParameterRangeValue.StartValue = myStartDate
End If
If txtEndDate.Text <> "" Then
myEndDate = txtEndDate.Text
Else
txtEndDate.Text = "2/22/1997 12:00:00AM"
myEndDate = txtEndDate.Text
crParameterRangeValue.EndValue = myEndDate
End If
'Set the 1st range and include the upper and lower bounds
With crParameterRangeValue
.EndValue = myEndDate
.LowerBoundType = RangeBoundType.BoundInclusive
.StartValue = myStartDate
.UpperBoundType = RangeBoundType.BoundInclusive
End With
'myStartDate = Nothing
'myEndDate = Nothing
'Apply the 1st range to the values to be passed to the viewer and
'reset the variables in preparation for setting the next range value
crParameterValues.Add(crParameterRangeValue)
'''Add the range current value for the parameter field
''crParameterValues.Add(crParameterRangeValue)
''Set the modified parameters collection back to the viewer so that
''the new parameter information can be used for the report.
CrystalReportViewer1.ParameterFieldInfo = crParameterFields
'crReportDocument = Nothing
End Sub
If I eliminate the parameters and hard-code the desired date range I get a report back that I can successfully navigate through the pages consecutively.
Has anyone else experienced this? I'm brand new to VB.NET and CR and I'm sure it's just my inexperience with these technologies that's causing me to overlook something simple. Any help would be greatly appreciated.
My code is shown below for convenience.
Thanks,
D. Porter
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Public Class DiscreteParmsEx
Inherits System.Web.UI.Page
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
Protected WithEvents btnRefresh As System.Web.UI.WebControls.Button
Protected WithEvents Calendar1 As System.Web.UI.WebControls.Calendar
Protected WithEvents lblStartDate As System.Web.UI.WebControls.Label
Protected WithEvents txtStartDate As System.Web.UI.WebControls.TextBox
Protected WithEvents lblEndDate As System.Web.UI.WebControls.Label
Protected WithEvents txtEndDate As System.Web.UI.WebControls.TextBox
Protected WithEvents btnStartDate As System.Web.UI.WebControls.Button
Protected WithEvents btnEndDate As System.Web.UI.WebControls.Button
Protected WithEvents LastPage_Button As System.Web.UI.WebControls.Button
Protected WithEvents Forward_Button As System.Web.UI.WebControls.Button
Protected WithEvents Back_Button As System.Web.UI.WebControls.Button
Protected WithEvents FirstPage_Button As System.Web.UI.WebControls.Button
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents btnExport As System.Web.UI.WebControls.Button
''CR Variables
Dim crReportDocument As OrderDetail
Dim crParameterFields As ParameterFields
Dim crParameterField As ParameterField
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterRangeValue As ParameterRangeValue
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
''Create an instance of the strongly-typed report object
crReportDocument = New OrderDetail()
''The viewer's reportsource must be set to a report before any
''parameter fields can be accessed.
CrystalReportViewer1.ReportSource = crReportDocument
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
''Get the collection of parameters from the report
crParameterFields = CrystalReportViewer1.ParameterFieldInfo
''Access the individual parameter field "Order Date Range"
crParameterField = crParameterFields.Item("Order Date Range"
'''Cast the variable to hold the values to pass to the viewer before execution
crParameterValues = crParameterField.CurrentValues
crParameterRangeValue = New ParameterRangeValue()
Dim myStartDate As DateTime
Dim myEndDate As DateTime
If txtStartDate.Text <> "" Then
myStartDate = txtStartDate.Text
Else
txtStartDate.Text = "2/18/1996 12:00:00AM"
myStartDate = txtStartDate.Text
crParameterRangeValue.StartValue = myStartDate
End If
If txtEndDate.Text <> "" Then
myEndDate = txtEndDate.Text
Else
txtEndDate.Text = "2/22/1997 12:00:00AM"
myEndDate = txtEndDate.Text
crParameterRangeValue.EndValue = myEndDate
End If
'Set the 1st range and include the upper and lower bounds
With crParameterRangeValue
.EndValue = myEndDate
.LowerBoundType = RangeBoundType.BoundInclusive
.StartValue = myStartDate
.UpperBoundType = RangeBoundType.BoundInclusive
End With
'myStartDate = Nothing
'myEndDate = Nothing
'Apply the 1st range to the values to be passed to the viewer and
'reset the variables in preparation for setting the next range value
crParameterValues.Add(crParameterRangeValue)
'''Add the range current value for the parameter field
''crParameterValues.Add(crParameterRangeValue)
''Set the modified parameters collection back to the viewer so that
''the new parameter information can be used for the report.
CrystalReportViewer1.ParameterFieldInfo = crParameterFields
'crReportDocument = Nothing
End Sub