Results 1 to 7 of 7

Thread: Combo Box

  1. #1
    Join Date
    May 2003
    Posts
    144

    Unanswered: Combo Box

    Is there a way to set a combo box to its first selection of the list? For example, if the combo box contains the following selections: "A Car", "A Boy". The combo box needs to show "A Car" when the form is open. I can't set the property "Default Value" because the selections on the combo box gets changed from time to time.

    Thanks

    SHK

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    As far as to my knowledge that is the only way to do it . Maybe you could set the default to an index number. That way if the actual text changes you will still have index 1 selected. (It all depends on what part of the information you store in your database.)

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: Combo Box

    Originally posted by SHK
    Is there a way to set a combo box to its first selection of the list? For example, if the combo box contains the following selections: "A Car", "A Boy". The combo box needs to show "A Car" when the form is open. I can't set the property "Default Value" because the selections on the combo box gets changed from time to time.

    Thanks

    SHK
    Is "A Car" in the visible column (bound column)? If so, just do: MyComboBoxName.Value="A Car"

  4. #4
    Join Date
    May 2003
    Posts
    144
    "A Car" is the bound column. However, MyComboBoxName.Value="A Car" will not work becuase "A Car" may not be on the selection list. The list can contain "A Boy", "A Girl". In this case, the combo box needs to show "A Boy".

    SHK

  5. #5
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Set the default value to:

    =DFirst("[NameOfField]","NameOfTable","WhateverCriteriaYouWant")
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  6. #6
    Join Date
    Apr 2004
    Location
    Kingsland, Georgia
    Posts
    231

    Re: Combo Box

    yes, sir. how about
    Code:
    Combo.Value = Combo.ItemData(1)
    that'll set the value to whatever the second item in the list is. to avoid errors, you may wanna throw in

    Code:
    If Combo.ListCount > 0 Then Combo.Value = Combo.ItemData(1)
    change the 0 to the number of the record you want to display-1. good luck.


    Originally posted by SHK
    Is there a way to set a combo box to its first selection of the list? For example, if the combo box contains the following selections: "A Car", "A Boy". The combo box needs to show "A Car" when the form is open. I can't set the property "Default Value" because the selections on the combo box gets changed from time to time.

    Thanks

    SHK

  7. #7
    Join Date
    May 2003
    Posts
    144
    Thanks all! mycombobox.value = mycombobox.ItemData(0) works!

Posting Permissions

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