• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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