Prev: RecordSource in VBA (Again)
Next: keep subform synchronized with main form in Microsoft Access 2003
From: bymarce on 21 Dec 2009 11:12 How can you programatically select items in a multiselect list box based on their lables? Certain groups of items in my multiselect listbox will be frequently selected together. I want to have check boxes elsewhere on the form that a user can click that will cause a group of items to be selected in the list box. The list box itself is used to make an sql statement. Thanks. Marcie
From: Dirk Goldgar on 21 Dec 2009 12:08 "bymarce" <bymarce(a)discussions.microsoft.com> wrote in message news:FF7548C3-FBE9-498B-9455-6EE50A8F2E17(a)microsoft.com... > How can you programatically select items in a multiselect list box based > on > their lables? Certain groups of items in my multiselect listbox will be > frequently selected together. I want to have check boxes elsewhere on the > form that a user can click that will cause a group of items to be selected > in > the list box. The list box itself is used to make an sql statement. > Thanks. > Marcie Hi, Marcie - I'm not sure what labels you're referring to, but you can select items in a multiselect list box by setting the row's .Selected property. In deciding whether or not to select a row, you can check the value of the bound column for that row by referring to the .ItemData property; or, if you need to look at some other column of the list box, you can use the .Column property. For example: '------ start of example code ------ Dim lngX As Long With Me.lstMyListbox For lngX = Abs(.ColumnHeads) To (.ListCount - 1) '---------> Use this line to test the row's bound-column value: ' If .ItemData(lngX) Like "ABC*" Then '---------> Use this line to test a particular column: If .Column(1, lngX) Like "ABC*" Then .Selected(lngX) = True End If Next End With '------ end of example code ------ -- Dirk Goldgar, MS Access MVP Access tips: www.datagnostics.com/tips.html (please reply to the newsgroup)
|
Pages: 1 Prev: RecordSource in VBA (Again) Next: keep subform synchronized with main form in Microsoft Access 2003 |