Thanks,
Jeff
The way I always handle this type of thing is to just change the sql of the query in code.
Seeing as you already have the complete sql statement built, just assign it to the query in question.
Dim qryDef As DAO.QueryDef
Set qryDef = CurrentDb.QueryDefs("yourQuery")
qryDef.Sql = strSql
Set qryDef = Nothing
That's it, your query now has the correct criteria
--
HTH
Dan Artuso, Access MVP
"Jeff Stroope" <JeffS...@discussions.microsoft.com> wrote in message news:6C809AE1-DD8C-4F55...@microsoft.com...
That's funny, I was just thinking about how to go about that myself. I
would like to also pick a group of names from a list of possible ones then
use them to generate a query for just those names.
You said you got help on how to generate the string statement. It is
probably through a loop run listbox.listcount times and checking if
selected is true or something like that. in VB I could do something like
this with ease. in Access, I haven't had experience. could you save me some
time and describe how this string variable is constructed. Thanks
"Steven Greenberg" wrote:
Steven,
The advice I got was to take a look at
http://www.mvps.org/access/forms/frm0007.htm at "The Access
Web"
I hope it works for you.
>
> http://www.mvps.org/access/forms/frm0007.htm
Thanks, I had already worked it out (and more) by now. It took a little
experimentation but I have it working perfectly.
http://www.mvps.org/access/forms/frm0007.htm
I have it so that I can select one value and have it come out as a list. The
problem is when I try to select additional values at the same time, no values
are returned in the list. I'm thinking that it's because I do not have the
separator incorrectly set up. I would prefer to use this rather than the sub
so that when I get it working, I can use it multiple times within the same
database. Any suggestions?
--
Duane Hookom
MS Access MVP
"Amery" <Am...@discussions.microsoft.com> wrote in message
news:5A2E5237-190C-439E...@microsoft.com...
Here's what I'm using:
SELECT [final output].name, [final output].Region, [final output].[Training
Type]
FROM [final output]
WHERE(( IsSelectedVar("Search","list10",[Region])=-1 ))
ORDER BY [final output].Region;
Do you know what I'm doing wrong?
Thanks...
"Duane Hookom" wrote:
> There is a generic function for multi-select list boxes with sample usage at
>http://www.access.hookom.net/Samples.htm
>
--
Duane Hookom
MS Access MVP
"Deb" <D...@discussions.microsoft.com> wrote in message
news:6B713ECB-AF05-451D...@microsoft.com...
Function IsSelectedVar( _
Search As String, _
list10 As String, _
Region As Variant) _
As Boolean
'strFormName is the name of the form
'strListBoxName is the name of the listbox
'varValue is the field to check against the listbox
Dim lbo As ListBox
Dim item As Variant
If IsNumeric(Region) Then
Region = Trim(Str(Region))
End If
Set lbo = Forms(Search)(list10)
For Each item In lbo.ItemsSelected
If lbo.ItemData(item) - varValue Then
IsSelectedVar = True
End If
Next
End Function
--
Duane Hookom
MS Access MVP
"Deb" <D...@discussions.microsoft.com> wrote in message
news:E55A3453-B4B4-4B45...@microsoft.com...
(thanks for all of your assistance - you've been very, very helpful with
this project)
Once again - thanks for all of your help.