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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Parameter In Query

Status
Not open for further replies.

orna

Programmer
Apr 2, 2002
314
IL
Hi

A query criteria is dinamic.
It looks like: In ("122005","012006")
I tried to insert a function that returns the whole sentence
or only what inside the brackets, and both ways are not working.
If i take the results of the function and place it in the
criteria, the query work ok.
Is there a way to do it?

TIA
 
Do you mean something like:
[tt]Dim qdf As QueryDef

strQry = "qryQuery"

Set qdf = CurrentDb.QueryDefs(strQry)

strIN = "'122005','012006'"
strSQL = "SELECT tblTable.ID From tblTable " _
& "WHERE tblTable.ID In ( " & strIN & ")"

qdf.sql = strSQL
DoCmd.OpenQuery strQry[/tt]
 
Thanks for quick answer!

but i need it in the query builder.
Have crosstab query that uses this query.
 
I do not quite understand what you wish to do. You may need to add parameters to your crosstab. [ponder]
 
I need the parameter in a regular query.
The crosstab is based on that query.
 
You'll need to do it Remou's way. The query designer won't accept a parameter as the contents of an IN clause and treat it as a comma-separated list of values. It will be treated as a single string that your field value must match.
 
Thanks Remou & Golom. I'll give it a try tomorrow morning.
 
Thanks Leslie!

I insert the parameter in the crosstab query and build it within the code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top