Search code examples
formsms-accessdata-bindingsubqueryms-access-2010

MSAccess Binding a Pulldown combobox to a sub-form


I have a multi-column pulldown combo box (cmb_users) that lists user names on a form (frm_myusers), the data is straight from a table called "dbo.my_users", primary key "pc_user_id", and it is the first column in the pulldown.

I then have a multi-form sub-form embedded into the parent form (frm_myusers) that contain one or more roles for each user. The data source is straight from a table called "dbo.my_users_roles" its primary key is pc_user_id. The relationship between dbo.my_users and dbo.my_users_roles is 1 to many.

enter image description here

The challenge I am having is When I try to bind the combobox to the sub-form I get the "cannot bind to an unbound form error"

enter image description here

So then I tried passing the combobox values to a query (qry_my_users_roles)behind the scenes to drive the sub-form. The criteria for the query was on pc_user_id as =[Forms]![frm_users]!cmb_users.Column(0), and I get the error below. Not sure where to go from here.

enter image description here

Ultimately is there a way to simply bind a pulldown to a sub-form without the need to jump through hoops passing variables to queries and refreshing? Mapping fields to query criteria can be quite cumbersome of the spelling or syntax is not absolutely perfect :(

Thanks in advance.


Solution

  • As the combobox is unbound, add it to the master fields:

    sci_cnt_id;NameOfCombobox
    

    and adjust the child fields as well:

    sci_cnt_id;sci_own_id
    

    Should you wish to show all records, you must maintain the field count, so use:

    sci_cnt_id;sci_cnt_id