• ListIndex (Access 2002 SP3)

    • This topic has 5 replies, 3 voices, and was last updated 20 years ago.
    Author
    Topic
    #420497

    I have an unbound combo box with the ListIndex = 0 using code on the On Got Focus event. The combo box is also hidden unless certain criterion is entered.

    Once there is data to populate the combo box. The Row Source is set using code and if the ListCount 0 then the combo box is now visible.

    This is what is giving me trouble.
    I get an error when the combo box is unhidden and has focus for the first time. The error I get is Run Time Error ‘7777’ You’ve use the ListIndex property incorrectly.

    If I set the combo box to visible when the form first opens the error does not happen when the combo box gets focus. Also when the error happens I can hit End instead of Debug and the next time I go to the combo box, it works just fine until it is hidden and unhidden again.

    Any ideas on what is happening.

    Thank you,

    Winston

    Viewing 1 reply thread
    Author
    Replies
    • #952343

      See if .Selected(0) = True works better (where is the name of your combo box)

      • #952390

        Hans,

        The combo box does not support this method or data member but a list box does.
        I want to remove the previous selected value from the combo box as it may no longer be the correct choice.
        I thought by selecting the first value in the combo box was the easy way of doing this.
        I added a database that creates the same error as the one I am working with.

        Thank You,

        Winston

        • #952406

          Sorry, I wasn’t paying attention when I posted my previous reply. Mark’s suggestion should do what you want:

          Me.Combo0 = Me.Combo0.ItemData(0)

          • #952529

            Thanks guys

            The Me.combo0 = Me.combo0.ItemData(0) Works perfect.

            Winston

    • #952386

      The ListIndex property is read-only. If this is a simple Listbox, you can use:
      lstWhatever = lstWhatever.ItemData(0)

    Viewing 1 reply thread
    Reply To: ListIndex (Access 2002 SP3)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: