how to change Value of listbox in VBA

AlanS

Registered User.
Local time
Yesterday, 20:34
Joined
Mar 23, 2001
Messages
292
I need to manipulate an Access 97 listbox in VBA code. The only way I've found to do this is with code like:

MyListBox.Selected(4) = True

which will select the fifth item in the listbox, and de-select whichever item was previously selected. So far so good.

However, when I then refer to the Value of the listbox in an expression, it still has the Value of the previously selected item, even though the fifth item is currently selected. How can I change the Value of the listbox to match the current selection?
 
My co-workers solved this one. I can simply directly assign a new value to the listbox, which both changes its value AND the selected item, like this:

MyListBox = [new value]
 

Users who are viewing this thread

Back
Top Bottom