Full Version: ListIndex property vs Selected property
UtterAccess Forums > Microsoft® Access > Access Forms
cboBox and lstBox both have the same row source (ordered the same, etc.), and when a value is selected from cboBox I want the same value to display as "selected" in lstBox. Here is the code I am using in the After Update event of cboBox:
im index As Integer
index = Me.cboBox.ListIndex
Me.lstBox.Selected(index) = True
Should the Selected and ListIndex properties be in synch the way I'm using them above?? When I select from cboBox the "selected" value in lstBox appears to be out by one.
If you are displaying ColumnHeads, this counts as a row...
Ahhhhh...that makes sense!! Good call, thanks for the super quick response!!!

Edited by: Rudeboy on Mon Aug 13 18:53:45 EDT 2007.
Edited by: Rudeboy on Mon Aug 13 19:01:59 EDT 2007.
you're welcome wink.gif happy to help
Hi Crystal,
The List Box has column headers while the Combo Box does not, however, if I add column headers to the Combo Box the exact same behaviour is exhibited with respect to the index values. Any other ideas, or maybe I should be approaching this differently?? I'll check back tomorrow, thanks again!
Hi (what is your name?)
Can you post the db and specify what to look at?
Setting an item as "Selected" is not the same as setting the value the list box returns. The "Selected" property is really intended for a Multi-Select list box, which I am assuming you are not using... So if the list box and combo box have the same row source I am assuming they have the same bound column, which is presumably unique.
o .... try this:
Me.lstBox = Me.cboBox
If that does not work (ie: your bound column is not unique or something else) ... then give this a try ...
HTH ...
PS> Howdy Crystal! ... -o!
Howdy stranger!
Thanks for jumping in, nice to see you!
Using Me.lstBox = Me.cboBox works...thanks for your help Brent and Crystal!!
You are quite welcome ... glad it worked out!
you're welcome, Donny wink.gif happy to help
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.