Last Selection List Box

chungiemo

New member
Local time
Today, 19:21
Joined
Jan 17, 2010
Messages
6
Hello,

I have a form where I add a new event, and it gets added to a list box in another form, I was intending to select the most up-to-date record within the list box but it seems to keep selecting the old latest record and not the new record that ive added. I had tried to select the first record but then move to the last record hoping it would refresh but that still doesn't work.

This is the code I used below:-

'Select last event record added to event list box
Me.lstPatientEvents = Me.lstPatientEvents.ItemData(Me.lstPatientEvents.ListCount - 1)
lstPatientEvents.Selected(lstPatientEvents.ListCount - 1) = True
 
Just an update as eventaully found a solution.

I just refreshed the listbox using MyListbox.Requery and had forgot to update my sort within the code. Which alloweed to me to select the newly added record at the bottom of the listbox.

Lastly to select the newly added comments it was reusing my code to pass in the ID and updating the textbox.

Thanks to all that had viewed the post:)
 

Users who are viewing this thread

Back
Top Bottom