Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Anderson, Indiana, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ListIndex (Access 2002 SP3)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ListIndex (Access 2002 SP3)

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

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: ListIndex (Access 2002 SP3)

    The ListIndex property is read-only. If this is a simple Listbox, you can use:
    lstWhatever = lstWhatever.ItemData(0)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Anderson, Indiana, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListIndex (Access 2002 SP3)

    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

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ListIndex (Access 2002 SP3)

    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)

  6. #6
    2 Star Lounger
    Join Date
    Mar 2005
    Location
    Anderson, Indiana, USA
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ListIndex (Access 2002 SP3)

    Thanks guys

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

    Winston

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •