Re: Move through a list box.



Hi Ron,

Well it is definately doing something. But it moves it to the ID in the
list that relates the previous record.

I did the following to test it:

Created a text box called txtBillHdn bound to the Bill field (the list box
contains a list of Bill numbers). Created a button called btnTstLst. On
the click event of btnTstLst I inserted your code:

Private Sub btntstLst_Click()

lstBill_List.Value = txtBillHdn
lstBill_List.Selected(lstBill_List.ListIndex) = True

'Basically two steps. First set the value of the list box to the newly
'created record ID and then make that row the selected item in the list.

End Sub

Then I went back to the form and used the navigator to go to record 4 with
a Bill value of 444444444. Textbox txtBillHdn is now 444444444. So I click
on btntstLst and it selects 333333333 from the list, the Bill value for
record 3. Any idea why that might be happening? Definately on the right
track though, the list selection is moving up and down.

TIA,

Jarryd

"Ron Weiner" <weinNoSpam1@xxxxxxxxxxxxxx> wrote in message
news:%23ZXrSEqvFHA.1996@xxxxxxxxxxxxxxxxxxxxxxx
> Try this
>
> lstBill_List.Value = TheNewBillValue
> lstBill_List.Selected(lstBill_List.ListIndex) = True
>
> Basically two steps. First set the value of the list box to the newly
> created record ID and then make that row the selected item in the list.
>
> --
> Ron W
> www.WorksRite.com
> "Jarryd" <Jarryd@xxxxxxxxxxxxxxxxxx> wrote in message
> news:OdK7wzovFHA.3236@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi,
>>
>> I have an unbound list box that is populated by a query. Clicking on a
>> value in the list box moves to the record in the recordset that matches
> the
>> value chosen in the list with a specified field:
>>
>> Private Sub lstBill_List_AfterUpdate()
>> Dim rs As Object
>>
>> Set rs = Me.Recordset.Clone
>> rs.FindFirst "[Bill] = '" & Me!lstBill_List & "'"
>> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
>>
>> End Sub
>>
>> Now that is working well. The next thing I have done is created a
> procedure
>> triggered by the Click event of a button to add a value to the table that
> is
>> queried to populate the list box. So the value is added and the list box
>> requeried. I have also got the form to move to the newly created record.
>> What I can't do is get the list box to move its position to the newly
> added
>> value. Does anyone know how you move through items in an unbound list
> box?
>>
>> TIA,
>>
>> Jarryd
>>
>>
>
>


.