Don you can use the ListIndex property to simulate the standard ListBox
TopIndex property.
http://www.lebans.com/List_Combo.htm#ScrollListbox
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
--
HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"Don Leverton" <My.Name@Telus.Net> wrote in message
news:%XTmc.6040$uN4.2535@clgrps12...[color=blue]
> Hi Jon,
>
> I don't think Bruce's method will do what he thinks it will ... but I[/color]
could[color=blue]
> be wrong ... go ahead and try.
>
> I think it will indeed "select" the first row that it fits the[/color]
criteria, but[color=blue]
> I doubt that it will scroll to it? AFAIK, there is no way to[/color]
automatically[color=blue]
> scroll to the desired row.
>
> Now I'm thinking that you may be able to limit the number of rows that[/color]
do[color=blue]
> get displayed in the list, and eliminate (or at least reduce) the need[/color]
for[color=blue]
> scrolling .
>
> This could be done by building an SQL string in code, and then using[/color]
that[color=blue]
> SQL as the Row Source for the listbox.
>
> Try this, and see if it suits your needs...
> (You will have to edit Table, Field, and Control Names ... )
>
> *******************************************
> Private Sub cmdRequeryListbox_Click()
>
> Dim strFilter
> Dim MySQL As String
> Dim whr As String
>
> strFilter = Me.txtFilter
>
> MySQL = ""
> MySQL = MySQL & "SELECT YourTableName.YourFieldName FROM YourTableName[/color]
"[color=blue]
>
> whr = ""
> If Len(strFilter) > 0 Then 'If the user has typed something to[/color]
narrow[color=blue]
> the search
>
> whr = whr & "WHERE (((YourTableName.YourFieldName ) Like "
>
> 'There are two ways to go here ... "Contains" OR "Begins With"
> 'eg "*pat*" would give you "Patrick Fitzsimons" AND "Simon[/color]
Fitzatrick"[color=blue]
> ' or "pat*" would return "Patrick Fitzsimons" only
> '--- this example is for "Contains ---"
>
> whr = whr & " '*' "
> whr = whr & " & "
> whr = whr & Chr$(34) & strFilter & Chr$(34)
> whr = whr & " & "
> whr = whr & " '*' "
> whr = whr & "))"
>
> MySQL = MySQL & whr 'Insert the WHERE into the SQL string
>
> End If
>
> MySQL = MySQL & ";"
> 'Debug.Print MySQL
>
> Me.lstFiltered.RowSource = MySQL
>
> End Sub
> *******************************************
>
> HTH,
> Don
>
> Jonathan LaRosa <jlarosa@alumni.brown.edu> wrote in message
> news:e6a1ce64.0405070504.65045b87@posting.google.c om...[color=green][color=darkred]
> > > Not trying to be a "smart-ass" ... but isn't that what a combo-box[/color][/color][/color]
does[color=blue]
> ...[color=green][color=darkred]
> > > without the need for a seperate textbox...?
> > > Let me qualify that ... a combobox with it's AutoExpand Property[/color][/color][/color]
set to[color=blue]
> True[color=green][color=darkred]
> > > (which is the default) will do that..[/color]
> >
> > yes, this is what a combo box does. except there is a requirement
> > that i did not mention that forces the use of a list box - the[/color][/color]
ability[color=blue][color=green]
> > to select multiple values. which means the combo box idea is out.
> >
> > thanks,
> > jon[/color]
>
>[/color]