By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,098 Members | 1,918 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,098 IT Pros & Developers. It's quick & easy.

selecting a record based on value in a combo box

P: 1
I have two tables. One of the table contains data on the individual while the other table has data on the organization/corporation. I have created combo box on the main form to select the organization/corporation with which the individual is associated. Now I would like to open a sub-form (using the open form command button) to display data of the organization/corporation I have selected in the combo box. Any help will be much appreciated.
Jan 4 '17 #1

✓ answered by NeoPa

If you're opening a form on the click of a button it's almost certainly NOT a sub-form (See Referring to Items on a Sub-Form).

To use a ComboBox control to help you filter from the existing data such that you can find a particular record more easily have a look at Cascaded Form Filtering or some of its linked pages.

Share this Question
Share on Google+
2 Replies


PhilOfWalton
Expert 100+
P: 1,430
Bit thin on information, so I shall make the following assumptions.

In your table of individuals you have a Foreign Key pointing to the Organisation to which the individual belongs.
Your main form is for the individual and you are using a Combo Box to select the appropriate organisation.
The Primary Key for the Organisation table is "OrganisationID" and the foreign key in the Individual table is also "OrganisationID"
The Combo Box is Bound to OrganisationID in the Individual Table.

Having created your subform ("SubOrganisation") based on the organisation, drag it onto the main form and set the LinkMasterFields & LinkChildField to "OrganisationID"

On the After Update of the Combo box, you need to refresh the subform so use something like this

Expand|Select|Wrap|Line Numbers
  1. Private Sub OrganisationID_AfterUpdate
  2.     SubOrganisation.Requery
  3. End Sub
  4.  
There are other alternatives methods without using a subform as well.

Phil
Jan 4 '17 #2

NeoPa
Expert Mod 15k+
P: 31,494
If you're opening a form on the click of a button it's almost certainly NOT a sub-form (See Referring to Items on a Sub-Form).

To use a ComboBox control to help you filter from the existing data such that you can find a particular record more easily have a look at Cascaded Form Filtering or some of its linked pages.
Jan 5 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.