Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2003
    Posts
    280

    Unanswered: How do you bound to two columns in a listbox?

    Example


    Supplier_Name Supplier_ID
    Coca Cola 1
    Sprite 2
    Pepsi 3

    When I click on the listbox, I want the supplier name and id to display in a textbox. One textbox for each column. Or is there another way to do this?

  2. #2
    Join Date
    Jun 2003
    Location
    Belgium
    Posts
    133
    There's no way you can bind 2 columns.
    However, in code you can always retrieve any column from a combo- or list box.

    Refer to a third column as follows :

    Me!cboCombo1.Column(2)

    Remark that the numbering is Zero-based!!
    Like this, you can retrieve any value from a selection in a combobox

  3. #3
    Join Date
    Apr 2003
    Posts
    280
    Oh, finally. Thank you!

    I have try alot of method, I would never thought of trying it your way.

  4. #4
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    18
    Originally posted by lansing
    Oh, finally. Thank you!

    I have try alot of method, I would never thought of trying it your way.


    Do u mean some like this?



    use a select statement like this:

    SELECT [Toystable Query].[ArticlelNr], [ToyTablel Query].[Articlename] FROM [ToyTablel Query] Where [ToyTable query].[available]=true;


    u can find more info about statements like these in acces helpfile
    Last edited by mrsplash; 10-11-03 at 07:13.

  5. #5
    Join Date
    Apr 2003
    Posts
    280
    No, your combo box or listbox only bound to one column. I wanted to bound to two columns or more. For example, when I click on a listbox, it would bound to the first and second column then display it in a textbox for each column of the row.

  6. #6
    Join Date
    Apr 2003
    Posts
    280
    No, your combo box or listbox only bound to one column. I wanted to bound to two columns or more. For example, when I click on a listbox, it would bound to the first and second column then display it in a textbox for each column of the row.

  7. #7
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    18
    Originally posted by lansing
    No, your combo box or listbox only bound to one column. I wanted to bound to two columns or more. For example, when I click on a listbox, it would bound to the first and second column then display it in a textbox for each column of the row.


    then i am afraid it will be not possible or very difficult to achieve this.
    keep on asking u might get the answer u need

  8. #8
    Join Date
    Oct 2003
    Location
    Boston, MA
    Posts
    15

    Re: How do you bound to two columns in a listbox?

    you could update your text boxes with a little code in the list box's AfterUpdate event:

    sub your_listbox_AfterUpdate

    me![text_box1] = dlookup("supplier_name","your_table_name","supplie r_name='" & me![your_listbox] & "'")


    me![text_box2] = dlookup("supplier_id","your_table_name","supplier_ name='" & me![your_listbox] & "'")


    end sub

  9. #9
    Join Date
    Apr 2003
    Posts
    280
    Originally posted by mrsplash
    then i am afraid it will be not possible or very difficult to achieve this.
    keep on asking u might get the answer u need
    Did you read the post from the other person before you posted your previous question?

    This way would work -------> Me!cboCombo1.Column(2)

Posting Permissions

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