all groups > sql server reporting services > november 2006 >
You're in the

sql server reporting services

group:

Problem with user prompt


Problem with user prompt Bruce Lawrence
11/29/2006 10:27:15 AM
sql server reporting services: I want to prompt the user for a specific ID number or use a * for all
records at the time of running the report

So in my criteria for the employee ID field I put "= @empid"

In the report the input box is there. If I put in an ID number it
works great. However if I put in an asterisk "*" nothing shows up.

Any ideas?
Re: Problem with user prompt Bruce Lawrence
11/29/2006 11:28:02 AM
Ok you lost me a little bit.

Here is my current where clause.

WHERE (pshstj.workday BETWEEN @StartDate AND @EndDate) AND (NOT
(pshstj.trn = 'RO1' OR
pshstj.trn = 'WO1' OR
pshstj.trn = 'XXX')) AND (pshstj.empid =
@ClockNo)

The "@clockno" section is where I prompt them for a clock number.
If I put a * it doesn't work. If I put a good number in it works fine.

Where does your 'where' clause fit into this?


[quoted text, click to view]
Re: Problem with user prompt Topher
11/29/2006 12:43:38 PM
I'd write an IIF statement (either in a stored procedure, or in the
Report Query):

IF @clockno = '*'
BEGIN

select ....
from ...
where (pshstj.workday BETWEEN @StartDate AND @EndDate) AND (NOT
(pshstj.trn = 'RO1' OR
pshstj.trn = 'WO1' OR
pshstj.trn = 'XXX'))

END

ELSE
BEGIN

select ..
from ..
where (pshstj.workday BETWEEN @StartDate AND @EndDate) AND (NOT
(pshstj.trn = 'RO1' OR
pshstj.trn = 'WO1' OR
pshstj.trn = 'XXX')) AND (pshstj.empid =
@ClockNo)

END



[quoted text, click to view]
Re: Problem with user prompt Andrei
11/29/2006 2:09:30 PM
Your where clause should be written like this:

where
(isnull(@EmpID, '*') = '*')
or ((isnull(@EmpID, 0) <> 0) and (EmpID = @EmpID))

this lets your users enter a value for EmpID (then the second part of the
where clause will deal with it)
or leave the parameter field empty - then all their records will be selected

You could also replace the '*' with a '' (empty string) - this way, if the
users leave the parameter field blank, it will behave like a '*'.

Andrei.


[quoted text, click to view]

Re: Problem with user prompt Andrei
11/29/2006 5:30:28 PM

WHERE (pshstj.workday BETWEEN @StartDate AND @EndDate)
AND (NOT
(pshstj.trn = 'RO1' OR
pshstj.trn = 'WO1' OR
pshstj.trn = 'XXX'))
AND
(
(isnull(@ClockNo, '*') = '*')
or
( (isnull(@ClockNo, '*') <> '*') and (pshstj.empid =
lockNo) )
)



[quoted text, click to view]

Re: Problem with user prompt Bruce Lawrence
11/30/2006 8:19:47 AM
Andrei,

I'm not sure how... but it works.

I love you
AddThis Social Bookmark Button