Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List Box Error 2

Status
Not open for further replies.

cstuart79

Technical User
Nov 2, 2009
171
US
i have an unbound list box with a long list of clients that is on the main form composed of multiple tabs. when selecting one client from the list box, the client name in the list remains highlighted and the scroll in the proper position as i click each tab. however, when i click back to the "main tab" the client name is no longer highlighted and the list goes back to the top even though the scroll bar stays in the proper position. how can i prevent this?
i have the following code in the after update:

Private Sub List367_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Client ID] = " & Str(Nz(Me![List367], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
List367.Requery
End Sub
 
tried your suggestion but same result. it seems that the correct record stays selected as the scroll bar does not move. it appears that the problem is only on the first tab. i noticed that if i click tab1, tab2, tab3 the list remains correct, click tab1 again and the list moves to the top, click tab2 again and the list is once again correct, also correct when clicking tab3 again. not sure what is different about tab1 that would cause it to show top of list?
 
How are ya cstuart79 . . .

It doesn't make any sense to requery a [blue]Listbox[/blue] after a selection is made unless the [blue]Row Source[/blue] is changed by selection!

Be more specific about this! . . .

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
i took out the requery and the problem remains--the record on the first tab will not stay selected after the list has lost focus while it does remain selected on the 2nd and 3rd tabs after the list has lost focus.
i don't understand why this occurs since it shouldn't be a focus issue due to the fact that records stay selected on 2nd and 3rd tabs. any suggestions??

Private Sub List367_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Client ID] = " & Str(Nz(Me![List367], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub
 
lol, sorry duane, haven't changed my poor naming conventions yet. List367 is unbound. i did check on current and after update events to see if focus would be moved off of list for some reason but cannot find anything. the strange thing is that after looking closer it appears the record does stay selected even on the 1st tab but the list needs to have the focus in order to show this. on the other 2 tabs the record stays selected on the list even when the focus is moved elsewhere. and the list on all 3 tabs is the same List367.
 
is there a way to keep the record selected even when focus is moved away from it? again, the record does stay selected on the 2nd and 3rd tabs but will not stay selected on the 1st tab. i don't see anything that would make the 1st tab behave any differently than the others.
 
thanks duane, but i just created a new tab with new subforms and it seems to work fine now. not sure what was wrong with the previous one but all is resolved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top