highlight top record in list box - after a delete (1 Viewer)

Rx_

Nothing In Moderation
Local time
Today, 02:36
Joined
Oct 22, 2009
Messages
2,803
Assume: Form tied to one single table
The form and list box have records for a single customer
Current record in form matches listbox record.

Delete button successfully deletes current record

Question:
After checking to see that the list box has at least 1 record left:

Automate selecting the top item in the listbox and clicking on it.
(code from clicking on a list box updates and does lots of fun things on the form)
 

Rx_

Nothing In Moderation
Local time
Today, 02:36
Joined
Oct 22, 2009
Messages
2,803
May have found the solution:
Question: is the ListBox 0 based or 1 based - i.e. Selected(0) or (1)
Tried it - found out that 0 picks the top record.
Added 4 records, deleted all the way down to 1.


' lst_FedAPDID name of list box
If Me.lst_FedAPDID.ListCount >= 0 Then
lst_FedAPDID.SetFocus
lst_FedAPDID.Requery
Me.lst_FedAPDID.Selected(1) = True ' this does the trick
Call lst_FedAPDID_AfterUpdate ' runs some cool code
Call lst_FedAPDID_Click ' refreshes bottom part of form
Else
' guess it is time to figure out what to do if No records are left

end if
 
Last edited:

Users who are viewing this thread

Top Bottom