parameters - Crystal Reports, Command statement, and SQL Server 2008 with variables -
i have rather involved command statement passing through crystal reports 2013 (cr) sql server 2008. there several static parameters created in cr static allow multiple values. way these parameters work end user either select "na" if not want search using particular criteria or if want search particular criteria, input values. 1 example searching medication. if end user wants find patients prescribed have been prescribed metformin, predisone, or albuteral in last year, input 3 names parameter field. if end user did not want search specific medications, type in "na".
to accommodate type of use, declared variables in command statement , wanted along lines of following:
declare @includerx varchar(254) declare @hasrx integer begin set @includerx = {?medicationnames} end if @includerx = 'na' begin set @hasrx = 0 end if @includerx <> 'na' begin set @hasrx = 1 end
the subsequent queries this:
if @hasrx = 1 begin select patient, medication_name, rx_date prescriptions medication_name in {?medicationnames} end if @hasrx = 0 begin select patient, medication_name, rx_date prescriptions end
if use 1 medication name, query , works fine. when try 2 or more medication names, error in crystal reports when run it.
is there way make work? can't create report in crystal directly , workaround i've found online use subreport not work in instance either.
Comments
Post a Comment