I have a Crystal Reports 8.5 report that uses a Stored Procedure as a data source. This Stored Procedure has a couple of parameters of which some are optional and require to be Null
when executing the procedure.
In VB6 I tried to clear the parameter but then Crystal Reports prompts the user to enter a value. Then I tried setting it to Nothing
but that gives an Invalid Type error. See the code below for an example of the ParameterField
part.
Dim crApp As CRAXDRT.Application
Dim crRep As CRAXDRT.Report
Set crApp = New CRAXDRT.Application
Set crRep = crApp.OpenReport(ReportFile, 1)
'Option 1
crRep.ParameterFields(1).ClearCurrentValueAndRange '<-- This won't set it to Null but it clears the current value. User gets a prompt to enter a value.
'Option 2
crRep.ParameterFields(1).ClearCurrentValueAndRange
crRep.ParameterFields(1).AddCurrentValue Nothing '<-- Setting it to nothing gives an error at runtime
So how to set a parameter to Null
at runtime?