I wrote a stored procedure on our SQL server; it's a relatively simple query pulling transactions since a date parameter that you enter. The stored procedure works; I can run it fine in SSMS.

I'm now trying to write VBA to pull the results into Excel, and I keep getting an automation error at the point where the stored procedure ("runsp") actually tries to run and pull the results into a recordset ("results"). I've tested the connection with a bit of code and it opens fine -- so the error is somewhere in running the stored procedure, or creating the recordset. I've tried creating the recordset with results.Open runsp and also with set results = runsp.Execute, and neither works.

Can anyone take a look at my code and give me any clue where I might be going wrong? Thanks so much.

https://pastebin.com/pjgDbpxa