Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adp Stored Procedure export to Excel

Status
Not open for further replies.

vbprgmr

Programmer
Dec 22, 2002
8
US
I am using Access 2000 and SQL 2000. I want to use a stored procedure (with 2 paramters) as the source for exporting to a spreadsheet.
This is similar to a post by GShen thread: 707-496426.
GShen found the answer to this, but I cannot get the code to work.

It works fine if I use:
lSQLExStr = "spMyProc"
DoCmd.OutputTo acOutputStoredProcedure, lSQLExStr, acFormatXLS, MyFileName & ".XLS"


But, it prompts for the 2 parms, as it should.

I have tried:
lSQLExStr = "spMyProc '" & lData1 & "', '" & lData2 & "'"
DoCmd.OutputTo acOutputStoredProcedure, lSQLExStr, acFormatXLS, MyFileName & ".XLS"


and also:
lSQLExStr = "spMyProc @parm1 = '" & lData1 & "', @parm2 = '" & lData2 & "'"
DoCmd.OutputTo acOutputStoredProcedure, lSQLExStr, acFormatXLS, MyFileName & ".XLS"


Get Runtime error '2757'
"There was a problem accessing a property or method of the OLE object."

Thanks in advance for any help!
vbprgmr
 
Figured it out ...
After 23 other attempts I finally used:
lSQLExStr = "EXEC spMyProc '" & lData1 & "', '" & lData2 & "'"
DoCmd.OutputTo acOutputStoredProcedure, lSQLExStr, acFormatXLS, MyFileName & ".XLS"


Tricky, tricky, tricky...
Hope this helps somebody.
vbprgmr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top