Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Posts
    30

    Unanswered: Binding multiple columns in a combobox

    Well, it is a pretty straight forward question. How do I bind each of the three columns in my combo box. I would love some direction on this. Thanks!

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Here's a straight-forward answer: you can't.

    What you can do is have 3 combo boxes. Run the first one, and have the second one's rowsource be a query with the first one's result as a WHERE clause. Do the same with the third combo box.

    For example: you have a table, tblClients with many duplicate names. Also, the addresses are duplicated sometimes. Only the email addresses are reliably unique. You would have 3 comboboxes with rowsources as follows:

    1 - select name from tblClients GROUP BY name

    At runtime, after running that cb, you would initialize the rowsource of the second cb:

    2 - select address from tblClients GROUP BY address WHERE name = cb1 (combo box 1 output field)

    Now initialize the 3rd cb:

    3 - select e_add from tblClients WHERE (name = cb1) and (address = cb2)

    This is not a good example for real life, because in this case you can go right to cb3 from cb1, without bothering with cb2. I'm only showing you an example where your scenario would be successful.

    Be careful: when the user is presented with the form, disable the cb2 and cb3to force him/her to run cb1 first. When he UPDATES cb1, enable cb2 and disable cb1 to prevent him/her from running it a second time. Also with the third cb.

    Good luck,
    Sam

  3. #3
    Join Date
    Apr 2011
    Posts
    30

    yep, that's a straight forward answer

    I was afraid of that. Good ole cascading combo boxes back in my life again. It is a simple work around... not the prettiest. Thanks for letting me know that what I want to do is not possible =)

  4. #4
    Join Date
    Mar 2013
    Posts
    1
    Perhaps you don't need binding?

    You can always do something like:
    1. "SELECT a, b, c, d FROM tbl;" as combobox rowsource
    2. Bind third column
    3. Read columns 1 and 2 using cmbBox.Column(0) and cmbBox.Column(1), then use these values in a code.

Tags for this Thread

Posting Permissions

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