• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1371
  • Last Modified:

Can't set listindex property of a combo box

Hi Experts,

I must be overlooking something.

me.combox.listindex = SomeInterger

Above statement generates error "7777"

Did this property suddenly became "read only"?

What is the proper method to set a combo box.

Any help will be highly appreciated.
I use Access 2002.

Daniel
0
danielmarkus
Asked:
danielmarkus
  • 4
  • 4
  • 4
  • +1
2 Solutions
 
peter57rCommented:
Hello danielmarkus,

use:
me.combox.setfocus
me.combox.listindex = SomeInterger


Pete
0
 
shanesuebsahakarnCommented:
One other cause of this error is trying to set the ListIndex to an invalid value (eg setting it to 100 when the list only contains 50 items).
0
 
harfangCommented:
Use instead:

    With Me.combox
        .Value = .ItemData(<a number>)
    End With

This is the equivalent of setting the .ListIndex, which is read only

Cheers :)
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
shanesuebsahakarnCommented:
No it isn't :-)
0
 
shanesuebsahakarnCommented:
I should qualify that - it isn't in A2K2 (and presumably in A2K), but is in A97.
0
 
peter57rCommented:
I think the confusion arises with what is meant by read/write for the Listindex property in Help.

You cannot change an entry's listindex value which I think is what is meant in Help when it describes the property as read-only.  But you certainly can set the combo box listindex value to select an item.   I think you could probably argue for ever over whether this constitutes 'write'.  
Help for Listindex has changed from A97 where it described the property as read/write in one entry and read-only in another to A2003 where it is said to be read-only but also includes an example of setting the value!

Anyway you can set the value.

Pete
0
 
harfangCommented:
Just checked again, it does not work in Access 2000 (can't try 2003 here).
Cheers:)
0
 
shanesuebsahakarnCommented:
Must be specific to A2K2 onwards - I skipped A2K completely :)
0
 
harfangCommented:
Well, ok, I resign :) The question did specify the version number...
(I just hope the .ItemData() wordaround still works in A2K+ !!!)
;)
0
 
peter57rCommented:
As far as i can see the code I gave in my first response works in every version of Access from (and including) A97 onwards. The setfocus command is always required.

Pete
0
 
harfangCommented:
This is not fair, I already resigned :(
I just tested your code, Pete, and of course it works. Now I must say: "I learned something"... here it goes:

Hey, I learned something! I never knew that!
(Thanke, Pete, I really didn't! And it does explain the strange error message, in a way...)

Cheers ;)
0
 
peter57rCommented:
All this for 50 points!
And the original poster hasn't made an appearance!

Hope it works for him!

Pete
0
 
danielmarkusAuthor Commented:
Sorry not to react immediately. Different timezone. Since both solutions worked in Access 2002 I rewarded both contributors.

BTW Great discussion. You should award me some points for initiating :)

Kind regards,

Daniel
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now