M
marshallartsoz
Hi, using Access2007, and want to select an item in a listbox in my VBA code.
I'm doing it like this:
Listbox.Selected(n) = True
This works, but only up to a point. The item certainly gets selected
visually in the listbox on the form, but believe it or not, the 'Value'
property of the listbox DOES NOT GET SET! I couldn't believe this, but I
have been through it several times in the debugger, and this is definitely
what is happening.
If the item is selected by clicking on it, the Value property is set as
expected. But setting the Select(n) property to True in code leaves the
Value property of the listbox unchanged - it remains at whatever it was
before. I have a subform which is linked to the main form using the value of
this listbox, so selecting the item programmatically means my subform does
not update correctly. My listbox RowSource is a query, if that makes any
difference.
Is there a way around this? I thought of setting the listbox Value property
myself, but it is readonly, so I cannot set it in code. Am I missing
something? This looks awfully like an Access/VBA bug to me.
I'm doing it like this:
Listbox.Selected(n) = True
This works, but only up to a point. The item certainly gets selected
visually in the listbox on the form, but believe it or not, the 'Value'
property of the listbox DOES NOT GET SET! I couldn't believe this, but I
have been through it several times in the debugger, and this is definitely
what is happening.
If the item is selected by clicking on it, the Value property is set as
expected. But setting the Select(n) property to True in code leaves the
Value property of the listbox unchanged - it remains at whatever it was
before. I have a subform which is linked to the main form using the value of
this listbox, so selecting the item programmatically means my subform does
not update correctly. My listbox RowSource is a query, if that makes any
difference.
Is there a way around this? I thought of setting the listbox Value property
myself, but it is readonly, so I cannot set it in code. Am I missing
something? This looks awfully like an Access/VBA bug to me.