Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter for an IN Stored Query

Status
Not open for further replies.

russellobrien

Programmer
May 14, 2003
28
GB
Just a quickie,

I am trying to use a stored query such as:

SELECT * FROM TABLE1 WHERE FACTOR1 IN (@List);

I then programmatically enter @List as 1,2,3,4,5 etc. However, it doesn't like this and seems to report an empty IN () clause.
Any help appreciated!

Russ
 
You can do something like this (this assumes datatype of factor1 is char()):

Sub in_qry()

Dim sSQL As String
sSQL = &quot;SELECT * FROM TABLE1 WHERE FACTOR1 IN (<<LIST>>)&quot;

Dim sList As String
sList = &quot;'AAA','BBB'&quot;

sSQL = Replace(sSQL, &quot;<<LIST>>&quot;, sList)

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset(sSQL)


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top