Full Version: ListIndex property vs Selected property
UtterAccess Forums > Microsoft® Access > Access Forms
Rudeboy
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.
strive4peace
If you are displaying ColumnHeads, this counts as a row...
Rudeboy
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.
strive4peace
you're welcome wink.gif happy to help
Rudeboy
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!
strive4peace
Hi (what is your name?)
Can you post the db and specify what to look at?
datAdrenaline
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 ...
Me.lstBox.ItemData(Me.cboBox.ListIndex)
HTH ...
PS> Howdy Crystal! ... -o!
strive4peace
Howdy stranger!
Thanks for jumping in, nice to see you!
Rudeboy
Using Me.lstBox = Me.cboBox works...thanks for your help Brent and Crystal!!
onny
datAdrenaline
You are quite welcome ... glad it worked out!
strive4peace
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.