Access Reports from SQL Server Stored Procedures

D

Drew

If I set up a Stored Proc in SQL Server, and using an Access ADP, I can
build a report from the Stored Procedure. All this works fine and dandy,
except when I add a paramter to the Stored Procedure. Like for instance,

CREATE PROCEDURE spCheckReceiving
@Shift int
AS
IF @Shift = 1
SELECT TOP 100 PERCENT E.EmpID, E.EmpFName, E.EmpMName, E.EmpLName,
EP.EmpSSN, P.PosTimeKeeper, D.DeptName
FROM dbo.tblEmpInfo EF INNER JOIN
EmpCore.dbo.tblEmployee E ON EF.EmpID = E.EmpID INNER
JOIN
EmpPersonal.dbo.tblEmpPersonalInfo EP ON E.EmpID =
EP.EmpID INNER JOIN
EmpCore.dbo.tblPosition P ON E.PosID = P.PosID INNER
JOIN
EmpCore.dbo.tblTimeKeepers TK ON P.PosTimeKeeper =
TK.TimeKeeperID INNER JOIN
EmpCore.dbo.tblDept D ON P.PosDeptID = D.DeptID
WHERE (E.EmpActive = 1) AND (EF.EmpDirectDeposit = 0) AND (E.EmpShift =
1 OR E.EmpShift = 2 OR E.EmpShift = 0)
ORDER BY E.EmpLName, E.EmpFName
ELSE
SELECT TOP 100 PERCENT E.EmpID, E.EmpFName, E.EmpMName, E.EmpLName,
EP.EmpSSN, P.PosTimeKeeper, D.DeptName
FROM dbo.tblEmpInfo EF INNER JOIN
EmpCore.dbo.tblEmployee E ON EF.EmpID = E.EmpID INNER
JOIN
EmpPersonal.dbo.tblEmpPersonalInfo EP ON E.EmpID =
EP.EmpID INNER JOIN
EmpCore.dbo.tblPosition P ON E.PosID = P.PosID INNER
JOIN
EmpCore.dbo.tblTimeKeepers TK ON P.PosTimeKeeper =
TK.TimeKeeperID INNER JOIN
EmpCore.dbo.tblDept D ON P.PosDeptID = D.DeptID
WHERE (E.EmpActive = 1) AND (EF.EmpDirectDeposit = 0) AND (E.EmpShift =
3)
ORDER BY E.EmpLName, E.EmpFName
GO

Now, if I set up a report with this stored procedure and run the report, it
will automatically prompt me for "Shift". Here if I enter 1 then it will
pass this to the SP and use the first query, if I put in anything but a 1
(2,3,etc) then it will run the 2nd query...

How can I get the input from the user on the stored procedure parameter? I
need to do this so that I can change up the grouplevel property if the
second query is used.

Thanks,
Drew Laing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top