Pass Parameters from Excel SQL Query

Jeffs23

New Member
Joined
Nov 15, 2009
Messages
6
Question: I am trying to pass a Stored Procedure through a worksheet with the following SQL and getting this Error - "Parameters are not allowed in queries that can't be displayed graphically".

My code is this - EXEC cusExcelMTD, ?, ?

I have seen that I need to use VB to alter my excel spreadsheet but I have no clue as to how to do this or the coding. The two parameters I want to pass are "StartDate" and "EndDate". Can someone please lend me hand?
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi

Welcome to the forum.

I assume you're using Excel 2003 and Access 2003.

Prior to your execute statements you need :-

Code:
Dim conn as ADODB.Connection
 
Set conn = CurrentProject.Connection

and then your execute should read like :-

Code:
conn.Execute "EXEC  cusExcelMTD " & Startdate & ", " & Enddate

Good luck

Mike
 
Upvote 0
Opps I did forget to post what version I am on - Its actually 2007 on my local machine and my client is using 2003 and its not to access its to SQL server. Does this matter?
 
Upvote 0
Can you describe more precisely how you are running this query, and what the data source for the query is? There's many ways to do these things and your post doesn't clarify the means by which you are running this query. Though, for what it's worth, EXEC looks like a SQL Server command to me too ...
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top