Results 1 to 7 of 7

Thread: Combo box entry based on the ItemData

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Combo box entry based on the ItemData

    How do you find a combo box entry based on the ItemData. I'm loading a combo box with entries from a description field. I'm using the primary key for that table as the item data for each description. Now if I know the primary key how do i display the correct item in the combo box. Here is a quick sample.

    Assume I have loaded a combo box with this data

    Apple ItemData = 1
    Orange ItemData = 2
    Banana ItemData = 4
    Grapes ItemData = 7

    Now lets say I know the itemData is 4. How would I display Banana

  2. #2
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Doesnt it have an Index X function, like a list box? Or am i misunderstanding something ? hehe
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    The listIndex is sequential. I can't use that because Items may have been delete in the table so the ItemData will not match the ListIndex

  4. #4
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    Ahh

    k
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by MarkT
    The listIndex is sequential. I can't use that because Items may have been delete in the table so the ItemData will not match the ListIndex
    Yes it will, the List and Itemdata may be two separate arrays, but they are synchronised. ie: Itemdata(3) will ALWAYS be the itemdata for List(3), no matter how many items have been removed/added.

    This means you can do a simple for loop on the itemdata, then set the listindex to the matching array position.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Cool, thanks!

  7. #7
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994

    Talking

    I knew it! hehe
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

Posting Permissions

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



Click Here to Expand Forum to Full Width