Skip to Content
0
Former Member
Apr 21, 2014 at 02:00 PM

Passing Parameters to HasValue in C#

57 Views

I have a report that is using HasValue in the report selection. So if a paramter has a value it will then select that value otherwise it will not use that value.

In the report, this is how the record selection looks with the hasvalue

(DISTRIBUTIONS.POSTDATE} in {@ParmStartDate} to {@ParmEndDate}) and

(If HasValue({?Account}) then {ACCOUNTS.ACCOUNTNUMBER} = {?Account} else true)

The issue is, what do I send to the report if I do not have a value to send. If the Account Array does not have any records, what do I send programitaccally to the report.

I've tried rpt.SetParameterValue("Account", false) and that does not work. I get no records. If I do not send anything the parameters window appears asking for the parameters.

In my code, I'm using

ParameterRangeValue DateRange = new ParameterRangeValue();

DateRange.StartValue = StartPostDate.Text;

DateRange.EndValue = EndPostDate.Text;

rpt.SetParameterValue("Post Date Range", DateRange);

For Account, it can be an array of accounts or no accounts.


Array Account = GetSelectedValues(AccountRange);
rpt.SetParameterValue("Account", Account);