Results 1 to 4 of 4

Thread: Bound ComboBox

  1. #1
    Join Date
    Jun 2005
    Posts
    102

    Unanswered: Bound ComboBox

    Hi guys,

    There's a field (lookup) on a table (table1) that looks up values on another table (table2). Now, I created a form for table1, the form automatically generated a combo box control for the field with a lookup. Now I created a unbound text box (txtBox1) on the form and on Form_Open procedure, I inserted this code

    Code:
    Private Sub Form_Open(Cancel As Integer)
       txtBox1 = lookup
    End Sub
    When the form opens, the value of lookup gets assign to txtBox1. But instead of the text appearing, a number appears. The lookup (combo box) is showing a string. But when I set it to equal to another control, it displays an integer. Now I know this is the index key, it is returning. How do I convert this to make it look exactly how the combo box is displaying it.
    The only true wisdom is in knowing you know nothing.

  2. #2
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    13
    Hey rodrunner79,

    It sounds like you need to refer to the correct column in you cboBox. Access starts numbering the columns at 0, so if there are 2 columns in your cboBox and the text string is in column 2 then the proper reference to it would be 1 so your code would need to change to:

    Private Sub Form_Open(Cancel As Integer)
    Me.txtBox1 = Me.lookup.Column(1)
    End Sub

    HTH,
    Shane

  3. #3
    Join Date
    Jun 2005
    Posts
    102
    Hey thanks.
    The only true wisdom is in knowing you know nothing.

  4. #4
    Join Date
    Dec 2005
    Location
    Texas
    Posts
    13
    Your welcome. Hope it works for ya.

    Shane

Posting Permissions

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