set listindex value

G

Guest

As we seem unable to set .ListIndex despite what it says in the Help files
(although it did work once, the first time through the code) I need another
way of display the last 5 items in the listbox, i.e. setting the 5th botton
item as Selected and display the 4 remianing items below it.

Any ideas, I am sure someone has done this before (not rocket science but
quirky)

Regards

Gordon Dale
 
M

Marshall Barton

GordonDale said:
As we seem unable to set .ListIndex despite what it says in the Help files
(although it did work once, the first time through the code) I need another
way of display the last 5 items in the listbox, i.e. setting the 5th botton
item as Selected and display the 4 remianing items below it.

Any ideas, I am sure someone has done this before (not rocket science but
quirky)


ListIndex is only settable when the listbox has the focus.
 
G

Guest

Thanks for the reply Marshall but using this code:

Dim L as Long

With OrderListBox
L = .ListCount
.ListIndex = L
End With

The code only worked first time I ran it therafter I received a compile
errorr '7777 ListIndex incorrectly used'

The help file says it is read only then contadicts itself by displaying the
code which I have adapted and tried to use. I have seen a few complaints in
this vein.

Any further help??

Regards

Gordon
 
G

Guest

Sorry Marshall

Meant to include .SetFocus in the 'With' above 'L = .ListCount'

Regards

Gordon
 
M

Marshall Barton

Please use Copy/Paste when you post code. It makes it
doubly difficult when we have to debug code with typos or
missing lines.

I don't understand why it works even once. The ListIndex
property is 0 based, so ListCount is always off the end of
the list.

This should work:

With OrderListBox
.SetFocus
If .ListCount > 0 Then .ListIndex = ListCount - 1
End With
 
G

Guest

Marshall

Talk about typo's

Took me a few minutes to work this one out.

ListCount should read .ListCount to reference List0, though the compiler did
not seem to care. I thought it should have been taken care of in the 'With
List0'. Difdference suppose between VBA and Delphi!!!

Anyway thanks a lot for your help. Saved me a few hours of head scratching

Regards

Gordon

Marshall Barton said:
Please use Copy/Paste when you post code. It makes it
doubly difficult when we have to debug code with typos or
missing lines.

I don't understand why it works even once. The ListIndex
property is 0 based, so ListCount is always off the end of
the list.

This should work:

With OrderListBox
.SetFocus
If .ListCount > 0 Then .ListIndex = ListCount - 1
End With
--
Marsh
MVP [MS Access]

Thanks for the reply Marshall but using this code:

Dim L as Long

With OrderListBox
L = .ListCount
.ListIndex = L
End With

The code only worked first time I ran it therafter I received a compile
errorr '7777 ListIndex incorrectly used'

The help file says it is read only then contadicts itself by displaying the
code which I have adapted and tried to use. I have seen a few complaints in
this vein.
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
E

eos

AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

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