Solved

How do I filter a subform based on a chosen record in a different subform?

Posted on 2014-11-21
8
184 Views
Last Modified: 2014-11-21
I have two subforms on a main form, "subfrm_Contacts" and "subfrm_Categories".  Both of them are in datasheet view.  "subfrm_Contacts" has as its record source a table, "tbl_Contacts", that contains, among other fields, an integer field called "IdCategory".  "subfrm_Categories" has as its record source a table, "tbl_Categories," with two fields:" IdCategory", an autonumber field, and "CategoryName", a text field.  "subfrm_Categories" only shows the text field which is a list of category names.  

I would like to create an event where when I click on a category name in the "subfrm_Categories",  "subfrm_Contacts" gets filtered to show only the records where tbl_Contacts.IdCategory = tbl_Categories.IdCategory.  What is the best way to do this?
0
Comment
Question by:Saleve
  • 4
  • 3
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40458542
it will be easier if you can post a copy of your db.
for the meantime see this link for reference

Refer to Form and Subform properties and controls
0
 

Author Comment

by:Saleve
ID: 40458564
Here it is.  Form "Main" has the two sub forms discussed above.  I would like to select a value in the "category" subform and have the "contacts" subform filter to only show the records in that category.
Contacts.accdb
0
 
LVL 35

Expert Comment

by:PatHartman
ID: 40458643
In the Master/Child links of sfrmB, refer to sfrmA as the "Master"

Master:sfrmA.Category
Child:Category

Then in the Current event of sfrmA, requery sfrmB
Me.Parent!sfrmB.Requery
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40458656
try this
Contacts.accdb
0
 

Author Comment

by:Saleve
ID: 40458660
I don't see how I can link two subforms with a master/child relationship.   Would you please explain?  Thanks.
0
 

Author Closing Comment

by:Saleve
ID: 40458664
Thanks Rey!  I will take a look at what you did, but it clearly works!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40458717
look at the click event of category textbox
0
 

Author Comment

by:Saleve
ID: 40458730
Yes, I see.  Very nice!  Thanks again.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question