Solved

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

Posted on 2014-11-21
8
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 37

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
Familiarize people with the process of utilizing SQL Server functions 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 Ac…

752 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