Results 1 to 4 of 4

Pass Parameters from Excel SQL Query

This is a discussion on Pass Parameters from Excel SQL Query within the Excel Questions forums, part of the Question Forums category; Question: I am trying to pass a Stored Procedure through a worksheet with the following SQL and getting this Error ...

  1. #1
    New Member
    Join Date
    Nov 2009
    Posts
    6

    Thumbs down Pass Parameters from Excel SQL Query

    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?

  2. #2
    Board Regular
    Join Date
    Jul 2009
    Location
    Woking UK
    Posts
    1,851

    Default Re: Pass Parameters from Excel SQL Query

    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

  3. #3
    New Member
    Join Date
    Nov 2009
    Posts
    6

    Default Re: Pass Parameters from Excel SQL Query

    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?

  4. #4
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    14,058

    Default Re: Pass Parameters from Excel SQL Query

    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 ...

    Using: Office 2007/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com