How to properly set a value on a multi-column combobox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vgarzon
    New Member
    • Dec 2009
    • 2

    How to properly set a value on a multi-column combobox

    Hi,

    I'm having issues setting a multi-column combobox in the right way.

    What I'm trying to do is that when I click on a table (access 2007 subform), a form should fill with the values of the record I clicked on.

    No problem until I have to fill correctly a multi-column combo for 2 reasons:

    - In the table I only have the value of one of the 2 columns (That can be solved if I query again one of my external tables, but if you have another way of doing it, I would appreciate it.... maybe something like mooving the selected option of a combo until it matches my value but no idea if that's possible)

    - When I try to set the value of the second column of my combo like this:
    Code:
      [Form_Tool Administration - Manage Users].CBoxProfile.Column(1) = Profile
    It gives me the following error message:
    Runtime Error 424: Object Required
    The funny thing is that it actually sets my second column to the value I want, but I keep having that error. The form, combobox control and column exist... and I actually have the right value in my variable "Profile".

    Could you help me with this issue, please?
  • vgarzon
    New Member
    • Dec 2009
    • 2

    #2
    Hi, After trying to do this for a while, I came up with the solution.

    I have a form to insert/modify users, and a sub-form to display the existing users. On a combobox, I have 2 columns, column 0 with some IDs and column 1 with their corresponding descriptions. On my sub-form I have several columns, including the description. The idea was to click on a user, and get all his data filled on the form.

    So I put this on the sub-form OnClick events:
    Code:
    'Get the description
        For copt = 0 To ([UserAdmin].CBoxProfile.ListCount - 1)
            If ([UserAdmin].CBoxProfile.Column(1, copt) = Description) Then
                    'Set the combobox to the corresponding value
                    [UserAdmin].CBoxProfile = [UserAdmin].CBoxProfile.ItemData(copt)
                Exit For
            End If
        Next copt

    Comment

    Working...