Highlight row in listbox PROBLEM

prometro

Registered User.
Local time
Today, 09:40
Joined
Aug 29, 2006
Messages
55
Hi,

i cannot solve this problem :

1) I have Listbox named Listbox1.
2) By clicking on it i can highlight for example row number 6.
3) Then I have button which do this :
Me.listbox1.Selected(3) = True

Ok, it works - row is highlighted right. But problem started when i run code : Me.listbox1.requery. Highlighting skips back to the previous row number 6.
But I need the highlighting stays at choosed number 3.

Can you help me with it?
Thank you
Jiri
 

Attachments

First save the list index to a variable and then reset it afterwards:
Code:
Dim lngRow As Long
 
lngRow = Me.listbox1.ListIndex
 
Me.listbox1.requery
 
Me.listbox1.Selected(lngRow) = True
 
Dear Bob, thank you this help ! Now it works.
I did form, where I choose value from Listbox1 by clicking
and it appears in Listbox2 by highlighting :

Dim lngRow As Long
Me.Listbox2.value = Me.Listbox1.value
lngRow = Me.Listbox2.ListIndex
Me.Listbox2.Selected(lngRow) = True

... so Me.Listbox2.requery doesnt change value like before.

Thank you
Bye
Jiri
 

Users who are viewing this thread

Back
Top Bottom