Multiselect Combo Box Initialization

  • Thread starter Thread starter Ilya
  • Start date Start date
I

Ilya

Hi Everybody:
How to select an item in the list of multiselect Combo Box
(say the last item in 200 items list) and bring it into
the visible part of Combobox?
The statement: Lst.Selected(198) = True
does not help to bring item up.
Thanks in advance for help.
Ilya.
 
Hi,



Here is a typical answer generally done by Stephen Lebans.


Hoping it may help,
Vanderghast, Access MVP

========
Scroll a ListBox to a specific row

Arrow keys to navigate a ListBox without the Focus

Scroll a ListBox to a specific row. Emulates the VB ListBox TopIndex
property. You can alter the code to easily have the selected row display
as the first or last row as well. The example code is placed behind a
Command Button.

' *** CODE START
Private Sub cmdListIndex_Click()
On Error GoTo Err_cmdListIndex_Click

' Always make NumRows an odd number
' if you want selected Row to be in the
' middle of the ListBox.

' NumRows is the number of completely visible rows in the ListBox Const
NumRows = 7
' Row we want displayed in middle of ListBox.
Dim intDesiredRow As Integer

' Arbitrarily select the 24th row.
intDesiredRow = 24
' ListBox must have the Focus
Me.List2.SetFocus
' Force ListBox to start from the top
Me.List2.ListIndex = 1

' Force the Scroll offset we desire
Me.List2.ListIndex = intDesiredRow + (NumRows / 2)
' Now select the row without further scrolling
Me.List2.ListIndex = intDesiredRow

Exit_cmdListIndex_Click:
Exit Sub

Err_cmdListIndex_Click:
MsgBox Err.Description
Resume Exit_cmdListIndex_Click

End Sub
' ***CODE END
=========
 
Back
Top