listbox, .selected and .listcount

G

Guest

Hi guys :)

When i click a button on this subform, I would like the last row of a
listbox called "listnotes" on the parent form to be selected. So in the
onClick of the button on the subform i put;

Me.Parent.ListNotes.Selected(Me.Parent.ListNotes.ListCount) = True

... but.....it........doesnt work.

Any suggestions?
Jeff



PS:

(I sperated the code into two lines, and each line worked well on its own;

Me.Parent.ListNotes.Selected(5) = true (selected row 5)
temp = Me.Parent.ListNotes.ListCount (temp returned the correct number of
rows)
 
D

Dirk Goldgar

WebDude said:
Hi guys :)

When i click a button on this subform, I would like the last row of a
listbox called "listnotes" on the parent form to be selected. So in
the onClick of the button on the subform i put;

Me.Parent.ListNotes.Selected(Me.Parent.ListNotes.ListCount) = True

.. but.....it........doesnt work.

Any suggestions?
Jeff



PS:

(I sperated the code into two lines, and each line worked well on its
own;

Me.Parent.ListNotes.Selected(5) = true (selected row 5)
temp = Me.Parent.ListNotes.ListCount (temp returned the correct
number of rows)

Are you sure those two lines are working the way you say? A list box's
rows are numbered from 0 to (.ListCount - 1), so I'd expect this to
work:

With Me.Parent.ListNotes
.Selected(.ListCount - 1) = True
End With

but not what you posted.
 
G

Guest

Dirk Goldgar said:
Are you sure those two lines are working the way you say? A list box's
rows are numbered from 0 to (.ListCount - 1), so I'd expect this to
work:

With Me.Parent.ListNotes
.Selected(.ListCount - 1) = True
End With

but not what you posted.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Hi

temp = Me.Parent.ListNotes.ListCount ...does appear to agree with the
number of rows i counted in the listbox. I double checked, and triple
checked. However, your code
Me.Parent.ListNotes.Selected(Me.Parent.ListNotes.ListCount-1) = True
does select the last row in the listbox. So,
Thank you!
Jeff
 
D

Dirk Goldgar

WebDude said:
Hi

temp = Me.Parent.ListNotes.ListCount ...does appear to agree with the
number of rows i counted in the listbox. I double checked, and triple
checked. However, your code
Me.Parent.ListNotes.Selected(Me.Parent.ListNotes.ListCount-1) = True
does select the last row in the listbox.

Yes, that's right. .ListCount might be 5, for example, meaning there
are 5 rows in the list box, but those rows are numbered from 0 to 4.
Thank you!

You're welcome.
 
G

Guest

Yes, that's right. .ListCount might be 5, for example, meaning there
are 5 rows in the list box, but those rows are numbered from 0 to 4.


OOOOOooohhh - now i understand,
thanks again! :)

WebDudeout
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top