The code I posted will create a string that can be used as a Where clause for
a query, but without the word WHERE.
I would suggest a command button to run the query or queries you need. To
call the function, you pass it the control object.
strWhere = BuildWhere(Me.List1)
Now, how you construct the query can be done a number of ways. You could do
it all in VBA:
strSQL = "SELECT [SOME_FIELD], [ANOTHER_FIELD-], [FOOTBALL_FIELD] FROM
tblAnyOldTable WHERE " & strWhere & ";"
Or you could use a stored query that has no criteria and add the criteria in
code:
strSQL = CurrentDb.QueryDefs("BaseQuery").SQL
strSQL = Replace(strSQL, ";", " WHERE " & strWhere & ";")
CurrentDb.QuerDefs("ProductionQuery").SQL = strSQL
With this technique, you create BaseQuery that pulls the data, but you never
actually use it. It is just there to store the SQL for you. This technique
is good if there is more than one place in your app you may use the same
unfiltered query.
Then, you save a modified version as ProductionQuery which now has the
filtering criteria. This will be the query you actually execute.
To set this up initially, you write BaseQuery and save it then make a copy
called ProductionQuery. That way it is there for the code above to use.
(Please use better names, this is only an example.
As to the second query, since I don't know what you are trying to
accomplish, I can't give any advice on that. See if you can get this part
working and if you need more assistance, post back with what you have so far
and what you want to do next.

Signature
Dave Hargis, Microsoft Access MVP
> My friend, thanks a lot for your answer,
>
[quoted text clipped - 65 lines]
> > >
> > > GeorgeCY
George - 28 May 2007 10:07 GMT
Thanks a lot Dave,
Your help is highly appreciated. I have also found a sample database to do
what I need to do at
http://www.rogersaccesslibrary.com/download3.asp?SampleName=CreateMultiSelectQue
ry.mdb
Have a nice day!
GeorgeCY
Ο χρήστης "Klatuu" έγγραψε:
> The code I posted will create a string that can be used as a Where clause for
> a query, but without the word WHERE.
[quoted text clipped - 103 lines]
> > > >
> > > > GeorgeCY