Question : DoCmd.OutputTo acOutputStoredProcedure fails with second parameter

I'm sure I'm missing something simple here. I'm using SQL-2000 with Access 2003.

This line in my Access code fails:
DoCmd.OutputTo acOutputStoredProcedure, strSP, acFormatXLS, strTmp & "StockStatus.xls", True
with the error
"Must pass parameter number 2 and subsequent parameters as 'name = value'

Debug.Print strSP shows
exec gsp_StockStatus @strCustCode='gapac', @strLocation='3018'

If I paste that into my SQL Query Analyzer it runs properly. But from the DoCmd.OutputTo it fails.
I've changed the stored procedure to only have one parameter and that makes it work ok.
But it fails with a second parameter. The stored procedure is shown below (I'm trying to make both parameters optional).

CREATE PROCEDURE dbo.gsp_StockStatus
(@strCustCode char(8) = null,
@strLocation char(50) = null)
AS
SELECT *
FROM  dbo.g_StockStatus
WHERE (@strCustCode Is Null OR CustCode = @strCustCode)
AND (@strLocation Is Null OR Location = @strLocation)
GO

Any ideas how to get this to work?

Answer : DoCmd.OutputTo acOutputStoredProcedure fails with second parameter

try setting strSP to be values only as parameters

e.g.

exec gsp_StockStatus 'gapac', '3018'
Random Solutions  
 
programming4us programming4us