Parameter Query

Ragnar78

Board Regular
Joined
Feb 10, 2004
Messages
210
Hy, i'm having problem setting parameters to query, parameter that are taken from Cells in sheets...
The query i started is a query i made outside excel wizard...i skiped everything in the wizard and got into the editor, press the SQL button and paste the query...

I would like tp know how i can set the parameters to be taken from excel cells, thank you (y)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Go into design view, enter something like the following in the parameter field:

[MyParamter]

This creates an input box in MSQuery. Now deliver your query back to Excel. Right-click in the query, select Parameters, and choose the option to get the parameter from a worksheet cell.

This is from memory, if it's slightly off, I apologize.
 
Upvote 0
First, if you get a warning that the query cannot be displayed in Microsoft Query you cannot use parameters. So anything complex is ruled out :(

Anyway, put question marks inside the query where you want to to place a parameter. When you press OK, Microsoft query will ask you for values for each ? in the query. Put in some values that will return you some data. Return the data to Excel.

In Data->Import External Data->Parameters... you can set each parameter to a cell of your choice.

Plz tell me if this works for you. Works like a charm for me... :)
 
Upvote 0
Tx alot...i'll be checking these tomorrow, we have DB maintanence....
Anyway i can edit the query and see the parameters...
and value (from what i remember) but still i cannot check the Paramter option..
so ill fix it and see if it works...

thx
(y)
 
Upvote 0
Anyway i can edit the query and see the parameters...
and value (from what i remember) but still i cannot check the Paramter option..
Did you test putting something in the parameter field in brackets?

E.g.,

[Whatever]
 
Upvote 0
well when i paste the query...i had already put in an argument in the 'close where'
That argument was (obviosly) shown in the SQL editor...
but i want it to check a value in a cell...and i couldn't get it.
 
Upvote 0
Yes, well, it's imperative that if you want to do what you are asking for, you must change your paramater value to [x] with the brackets in design mode. What goes in between does not matter. Whatever you want, just as long as there are brackets.

Some examples might include:

[Zut Alors!]
[Fruity Pebbles]


It does not matter where, deisgn mode, sql view. Here's the example of sql:

WHERE Blah1 = blah AND Blah2 = blahblah AND blah3=?

But it's easier to do this in design view:

Criteria Field: Field X
Value: [Sacre Bleu]

Return the data, then right-click, Parameters... Use option 3. Voila.

N'est pas?
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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