Parameter query with a variable "IN" clause

  • Thread starter Thread starter solex
  • Start date Start date
S

solex

Hello,

I have created a query which gets it criteria from a function. The function
returns the selection of a combo box in a tool bar. The user can select a
single year from the combo box or choose the item "<ALL>" which represents
all years.

The problem I am having is that the IN clause will not except a string list
of years, although it will except an integer representing a single year. Is
there a way to return a list of integers to the query (I have tried an array
but this does not work.)

Thanks,
Dan
 
Is this query bound to a form or report? If so, you'd be better off using
the WhereCondition parameter on OpenForm or OpenReport and remove the
parameter from the query. Your code that performs the filtered open could
still call the function:

Dim strWhere as String

strWhere = "SomeField IN (" & YourFunction() & ")"
DoCmd.OpenForm "frmResults", WhereCondition:=strWhere

--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
 
John,

Thanks for your response, I will take this under advisment..

Regards,
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top