Easy combo box question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mason Wood

    Easy combo box question

    I have another question for the community, and hopefully it's an easy
    one. It seems ridiculously simple, but I can't find anything on it.

    I have a combo box that is bound to a table. When a form is opened, I'd
    like the current value of said combo box to be dictated by a value given
    by the previous form. For the life of me, I can't figure out how to use
    code to set the current value of a combo box. Here is the simple code,
    taken right from a book, that I'm trying to work with.

    Dim i As Integer

    With Me!cboCustomer
    For i = 0 To .ListCount - 1
    If .Column(3, i) = Me!tboCustomerN umber Then
    .Selected(i) = True <----------------------------------
    Exit For
    End If
    Next i
    End With

    The line with the arrow pointing to it is where it breaks down, as the
    code was written for a list box. A combo box has no .Selected property,
    and I can't find anything that is its equivalent.

    Any help would be greatly appreciated.

    Mason

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • Phil Stanton

    #2
    Re: Easy combo box question

    Try a global constant possibly CustNo as Long. This must be declared in an
    indipendent Module (ie one not bound to a form.
    Assuming the bound column in the Combo box is bound to tboCustomerNumb er,
    then OnClose of the previous form set CustNo = tboCustomerNumb er and OnOpen
    of the new form set Me!ComboBox = CustNo.

    Phil





    "Mason Wood" <mason@codemonk ey.cc> wrote in message
    news:3f9d9a59$0 $195$75868355@n ews.frii.net...[color=blue]
    > I have another question for the community, and hopefully it's an easy
    > one. It seems ridiculously simple, but I can't find anything on it.
    >
    > I have a combo box that is bound to a table. When a form is opened, I'd
    > like the current value of said combo box to be dictated by a value given
    > by the previous form. For the life of me, I can't figure out how to use
    > code to set the current value of a combo box. Here is the simple code,
    > taken right from a book, that I'm trying to work with.
    >
    > Dim i As Integer
    >
    > With Me!cboCustomer
    > For i = 0 To .ListCount - 1
    > If .Column(3, i) = Me!tboCustomerN umber Then
    > .Selected(i) = True <----------------------------------
    > Exit For
    > End If
    > Next i
    > End With
    >
    > The line with the arrow pointing to it is where it breaks down, as the
    > code was written for a list box. A combo box has no .Selected property,
    > and I can't find anything that is its equivalent.
    >
    > Any help would be greatly appreciated.
    >
    > Mason
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it![/color]


    Comment

    • Mason Wood

      #3
      Re: Easy combo box question



      Thanks for the response, Phil. Worked great!

      Mason

      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...