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
LVL 1
danielmarkusAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.