There is a generic list box function at http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane. This can be used in your maketable query.
-- Duane Hookom MS Access MVP
"SEAN DI''''ANNO" <SEANDIANNO[ at ]discussions.microsoft.com> wrote in message news:9B179628-3E74-4B93-849B-ED04566F46AA[ at ]microsoft.com...
[Quoted Text] > Good morning all, > > I managed to get the code below to choose ultiple entrues in a listbox and > then filter a report using strwhere. I was hoping I could use the same > technique to run a make table query filtering the results also by > strwhere. > In the code below, SelectCategory is the name of the listbox and I am > using > it to allow users to choose names from a list. THerefore the query pulls > out > froma database all the entries with the names chosen. Can some one > please > be kind enough to provide me with code for acheiving this. > > Thank you in advance > > With Me.SelectCategory > For Each varItem In .ItemsSelected > If Not IsNull(varItem) Then > 'Build up the filter from the bound column (hidden). > strWhere = strWhere & strDelim & .ItemData(varItem) & > strDelim & "," > 'Build up the description from the text in the visible > column. See note 2. > strDescrip = strDescrip & """" & .Column(1, varItem) & """, > " > End If > Next > End With > > 'Remove trailing comma. Add field name, IN operator, and brackets. > lngLen = Len(strWhere) - 1 > If lngLen > 0 Then > strWhere = "[OperatorName] IN (" & Left$(strWhere, lngLen) & ")" > lngLen = Len(strDescrip) - 2 > If lngLen > 0 Then > strDescrip = "TeamName: " & Left$(strDescrip, lngLen) > End If > End If > > > Me.QueryFilter = strWhere
|