Solved

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

Posted on 2014-11-21
8
182 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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 …

770 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