+ Reply to Thread
Results 1 to 5 of 5

Add parameter manually to command text

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    United States, OHIO
    MS-Off Ver
    2007
    Posts
    3

    Add parameter manually to command text

    EXCEL 2007

    Hey guys,

    So heres my problem...

    I wrote a SQL query without using the wizard or ms query. It connects to a SQLOLEDB. Now all I need to do is add a couple parameters to be defined from within the workbook. I cannot get the parameters option to not be grayed out under connection properties.

    Supposedly when you put a question mark into the command text it should propt you to define the parameter. When I run the simple query attached I just get an error stating that the param is not defined.

    What should I do?

    Thanks
    -Chris
    Attached Images Attached Images

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Add parameter manually to command text

    I haven't gone down this road this way, but is there any reason that you cannot write your parameter directly into your WHERE clause

    something like WHERE taskisactive = "Yes";
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    United States, OHIO
    MS-Off Ver
    2007
    Posts
    3

    Re: Add parameter manually to command text

    The problem is that I need the parameter to ultimately be determined by a vba menu like a check box list. My query is the basis for a chart. I need users to be able to select the data category to be displayed.

    Theres over 1000 ways the data can be spun so I can't build individual reports.

    it would look something like :

    select enginetype from table where carcolor = ?

    Then have a checkbox menu listing [ red, blue, green ].

    Right now I simply have no way to define the parameters from within the workbook

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Add parameter manually to command text

    Found this while looking for something else. Thought it might be helpful to your cause.

    http://datapigtechnologies.com/blog/...one-parameter/

  5. #5
    Registered User
    Join Date
    11-27-2012
    Location
    United States, OHIO
    MS-Off Ver
    2007
    Posts
    3

    Re: Add parameter manually to command text

    I essentailly found that my command string is too complicated to add parameters to. If I try adding one, I get an error saying that there are too many rows.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1