Results 1 to 2 of 2
  1. #1
    tomodachi is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2010
    Posts
    1

    Selected items in listbox

    HI Guys! I really really need your help here and will really appreciate any answers.
    I got a listbox in a form in MS Access that is set to simple for selecting multiple criterias.



    I run a function, GetCriteria in the module. I want to call GetCriteria function in an sql query. In this function, GetNumber() is another function in the module which I called in GetCriteria().

    Currently, these codes does not call the query outputFunction2 for the selected items. It only calls the item of the listbox regardless of if it being selected or not. I know I am able to replace GetNumber()-1 with varItem in GetCriteria Function. However,this will cause the last selected item to override the output of the getCriteria function for the other selected items and it will only run one query.

    GetNumber() on the other hand, does not take into consideration the selected items..

    I really dont know what to do.

    Thank you.



    Function GetCriteria()
    With [Forms]![csrsrs]![ClientsList]
    For Each VarItem In .ItemsSelected
    If Not IsNull(VarItem) Then
    StrWhere = .ItemData(GetNumber() - 1)
    End If
    Next VarItem
    End With
    GetCriteria = StrWhere
    End Function

    Function GetNumber()
    GetNumber = LoopCounter
    End Function

    Public Sub Alpha()
    LoopCounter = 1
    While LoopCounter <= [Forms]![csrsrs]![ClientsList].ItemsSelected.Count
    DoCmd.OpenQuery ("outputFunction2")
    LoopCounter = LoopCounter + 1
    Wend

    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'm not clear what that's supposed to do. There would be no relationship between LoopCounter and the selected item. If you're trying to open a report filtered to the selected items, I'd do this:

    http://www.baldyweb.com/multiselect.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-17-2010, 02:33 PM
  2. Exporting report selected from a listbox to excel
    By GARCHDEA in forum Import/Export Data
    Replies: 1
    Last Post: 08-10-2010, 07:45 AM
  3. Query Not Listing All Items
    By Rawb in forum Queries
    Replies: 7
    Last Post: 05-14-2010, 08:00 AM
  4. Items at reorder point
    By MFS in forum Queries
    Replies: 2
    Last Post: 04-01-2010, 11:43 AM
  5. list box items
    By thewabit in forum Forms
    Replies: 12
    Last Post: 01-01-2010, 08:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums