Page 1 of 1

Using Variables

Posted: Mon Jan 27, 2014 9:20 pm
by rumblecow
I've defined a report with the following datasource

Code: Select all

SELECT	TransDate,		
	SiteID,
	Item,
	ItemClass,
	Description1,
	TypeDescription,
	CostSum,
	QtySum
	FROM	TRANSDay (nolock)
WHERE	(TypeDescription IN ('ADJUS', 'CANCL', 'COUNT', 'ISSRT', 'ISSUE', 'RETN', 'RETNW', 'SCRAP', 'SCRPR'))
		AND (Transdate >= @pFromDate AND TransDate < @pToDate)
		AND (ItemClass = @pItemClass)
		AND (SiteID = @pSiteID)
		AND vConsignment
And setting the variable as follows:

Code: Select all

 switch (r.Consignment)
            {
                case 0:
                    report.Dictionary.Variables.Add("vConsignment", " (1=1 or Consignment =1)");
                    break;
                case 1:
                    report.Dictionary.Variables.Add("vConsignment", " (Consignment = 1)");
                    break;
                case 2:
                    report.Dictionary.Variables.Add("vConsignment", " (Consignment is null or consignment = 0)");
                    break;
                default:
                    break;
            }

But receiving the exception: "An expression of non-boolean type specified in a context where a condition is expected, near 'vConsignment'." What am I doing wrong???

Re: Using Variables

Posted: Tue Jan 28, 2014 7:48 am
by Alex K.
Hello,

Please try to use the following query:

Code: Select all

WHERE  ...
      AND {vConsignment}
Thank you.