I have crystal report set with optional parameters. In crystal report it works fine. If parameter is selected it opens with filter data, if no parameter selected, report opens with all data. I have code in record selection formula editor as follows:
(not HasValue({?PF}) or {Command.Product_Family} = {?PF})
My report opens with correct data when I pass required parameter from Application. But if I do not pass parameter, report opens with no data. Below is my code, please suggest what to modify to make it work so if no parameter value is selected, report should open with all the data and if parameter values is passed then with filter data based on parameter values.
Dim PF_pField As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
dim PF_currentValues as CrystalDecisions.Shared.ParameterValues
PF_pField = PFields.Item("PF")
PF_pField.CurrentValues.clear()
PF_pField.CurrentValues.IsNoValue = true
PF_currentValues = PF_pField.CurrentValues
For Each item In Me.Product_FamilyFilter.Items
If item.Selected AndAlso (item.Value = "
ANY
" OrElse item.Value = "
PLEASE_SELECT
") AndAlso selectedItemCount > 1 Then
item.Selected = False
End If
If item.Selected Then
ParamValue= New CrystalDecisions.Shared.ParameterDiscreteValue()
paramValue.Value = item.value
PF_currentValues.Add(paramValue)
End If
Next
PF_pField.ApplyCurrentValues(PF_currentValues)
crReportDocument.SetParameterValue("PF", PF_currentValues)