Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

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

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
Saleve
Asked:
Saleve
  • 4
  • 3
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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
 
SaleveAuthor Commented:
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
 
PatHartmanCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Rey Obrero (Capricorn1)Commented:
try this
Contacts.accdb
0
 
SaleveAuthor Commented:
I don't see how I can link two subforms with a master/child relationship.   Would you please explain?  Thanks.
0
 
SaleveAuthor Commented:
Thanks Rey!  I will take a look at what you did, but it clearly works!
0
 
Rey Obrero (Capricorn1)Commented:
look at the click event of category textbox
0
 
SaleveAuthor Commented:
Yes, I see.  Very nice!  Thanks again.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now