Parameter query using In

PHodgson

New Member
Joined
Mar 1, 2005
Messages
2
I am trying to make an MS Query interactive based on a list of values.
The usual SQL syntax for the selection is something on the lines of:
Where Fieldname In ('Value1','Value2','Value3)
However I'm trying to make this a parameter query, so my syntax is:
Where Fieldname In (?)

When the parameter dialog opens for the value list to be entered, what should the syntax of the reponse be ?

I've tried:
Value1
on it's own, this works. However, for a list of values it does not seem to work as I must have the wrong sytax. I've tried:

'Value1','Value2'
Value1, Value2
('Value1','Value2')
etc., but none seem to work. Any ideas ?
 

Some videos you may like

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

Mark W.

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,654
The placeholder for a parameter is a scalar -- not an array. Try this...

SELECT List.Fruit, List.Qty
FROM Book1.List List
WHERE (List.Fruit=?) OR (List.Fruit=?)
 

PHodgson

New Member
Joined
Mar 1, 2005
Messages
2
Mark,
I understand if the number of values is known and in your example is 2, but the reason for using the In syntax was to allow multiple values to be entered at query run time, and not the same number of values each time.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,463
Messages
5,596,284
Members
414,051
Latest member
tabecker

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
Top