From: Goldar on 26 Apr 2010 16:17 I'm confused about what events occur with a multi-select list box. When I select an item from the box (shift-click), does the Click event or the AfterUpdate event occur? How do I return control to my program after making my selection(s) from the list box? In other words, how does the list box know that I'm done making selections? Thanks,
From: Jeanette Cunningham on 26 Apr 2010 21:01 The listbox doesn't know when you are finished making selections. However, after you click away from the listbox, the form (or access) can read the list of selected items in the listbox and use that list. Here is some code from Graham Mandeno which shows how to capture that list of selected items. --------------------------------- Public Function MultiSelectSQL(ctl As Control, _ Optional Delimiter As String) As String Dim sResult As String, vItem As Variant With ctl Select Case .ItemsSelected.Count Case 0: sResult = " Is Null " Case 1: sResult = " = " & Delimiter & .ItemData(.ItemsSelected(0)) & Delimiter Case Else sResult = " in (" For Each vItem In .ItemsSelected sResult = sResult & Delimiter & .ItemData(vItem) & Delimiter & "," Next vItem Mid(sResult, Len(sResult), 1) = ")" End Select End With MultiSelectSQL = sResult End Function ---------------------------------- Just paste the code above into a standard module. If the bound column of your listbox is not numeric, you will need to pass a double-quote as a delimiter. For example: MultiSelectSQL( lstNames, """" ) Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "Goldar" <Goldar(a)discussions.microsoft.com> wrote in message news:C944630E-C2CB-4ED0-BAFE-AF5668C62976(a)microsoft.com... > I'm confused about what events occur with a multi-select list box. When I > select an item from the box (shift-click), does the Click event or the > AfterUpdate event occur? How do I return control to my program after > making > my selection(s) from the list box? In other words, how does the list box > know > that I'm done making selections? > > Thanks, > >
|
Pages: 1 Prev: PLEASE HELP: Send email from Access with data in email body Next: How to use Or in txrbox |