fcoit
asked on
Crystal Reports - Enter parameter values window appears
Hello experts,
I am learning to program in Visual Basic 2005 for Crystal Reports. I am following the Walkthroughs included with Visual Studio 2005. I doing the chapterfor "Setting parameters for a report." When the report opens inside the Form in the CrystalReportViewer control everything works just fine. But when I try to refresh the report I get the [Enter Parameter Values] window, even though the parameters are already being provided. Any help will be greatly appreciated. Thank you.
I am learning to program in Visual Basic 2005 for Crystal Reports. I am following the Walkthroughs included with Visual Studio 2005. I doing the chapterfor "Setting parameters for a report." When the report opens inside the Form in the CrystalReportViewer control everything works just fine. But when I try to refresh the report I get the [Enter Parameter Values] window, even though the parameters are already being provided. Any help will be greatly appreciated. Thank you.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Collections
Public Class Form2
Private Const PARAMETER_FIELD_NAME As String = "City"
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ConfigureCrystalReports()
End Sub
Private Sub ConfigureCrystalReports()
Dim myArrayList As ArrayList = New ArrayList()
myArrayList.Add("Paris")
myArrayList.Add("Tokyo")
Dim reportPath As String = Application.StartupPath & "\CustomersByCity.rpt"
myCrystalReportViewer.ReportSource = reportPath
Dim myParameterFields As ParameterFields = myCrystalReportViewer.ParameterFieldInfo
SetCurrentValuesForParameterField(myParameterFields, myArrayList)
defaultParameterValuesList.DataSource = GetDefaultValuesFromParameterField(myParameterFields)
End Sub
Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)
Dim myTableLogOnInfos As TableLogOnInfos = myCrystalReportViewer.LogOnInfo
For Each myTableLogOnInfo As TableLogOnInfo In myTableLogOnInfos
myTableLogOnInfo.ConnectionInfo = myConnectionInfo
Next
End Sub
Private Sub SetCurrentValuesForParameterField(ByVal myParameterFields As ParameterFields, ByVal myArrayList As ArrayList)
Dim currentParameterValues As ParameterValues = New ParameterValues()
For Each submittedValue As Object In myArrayList
Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
myParameterDiscreteValue.Value = submittedValue.ToString()
currentParameterValues.Add(myParameterDiscreteValue)
Next
Dim myParameterField As ParameterField = myParameterFields(PARAMETER_FIELD_NAME)
myParameterField.CurrentValues = currentParameterValues
End Sub
Private Function GetDefaultValuesFromParameterField(ByVal myParameterFields As ParameterFields) As ArrayList
Dim myParameterField As ParameterField = myParameterFields(PARAMETER_FIELD_NAME)
Dim defaultParameterValues As ParameterValues = myParameterField.DefaultValues
Dim myArrayList As ArrayList = New ArrayList()
For Each myParameterValue As ParameterValue In defaultParameterValues
If (Not myParameterValue.IsRange) Then
Dim myParameterDiscreteValue As ParameterDiscreteValue = CType(myParameterValue, ParameterDiscreteValue)
myArrayList.Add(myParameterDiscreteValue.Value.ToString())
End If
Next
Return myArrayList
End Function
Private Sub redisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles redisplay.Click
Dim myArrayList As ArrayList = New ArrayList()
For Each item As String In defaultParameterValuesList.SelectedItems
myArrayList.Add(item)
Next
Dim reportPath As String = Application.StartupPath & "\CustomersByCity.rpt"
myCrystalReportViewer.ReportSource = reportPath
Dim myParameterFields As ParameterFields = myCrystalReportViewer.ParameterFieldInfo
SetCurrentValuesForParameterField(myParameterFields, myArrayList)
defaultParameterValuesList.DataSource = GetDefaultValuesFromParameterField(myParameterFields)
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi fcoit did you not try crystaldecisions.crystalre ports.engi ne.reportd ocument ?
ASKER
For the record this is a problem with Crystal Report 10 for Visual Basic, which has not been resolved by CR. Specially with Windows Vista I have not tested it in XP though.
ASKER
I tried it in the redisplay event, but I do not see the SetParameter option for the ReportDocument statement. Which library do I need to import? Where do I enter the ReportDocument.SetParamete