Results 1 to 6 of 6
  1. #1
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65

    Filter Subform From Another Subform

    I want to filter a subform (TrainingTopics Subform) by its category Field by double-clicking on the Category field in another subform (TrainingQry2 subform).



    Click image for larger version. 

Name:	TrainingDBPic.jpg 
Views:	5 
Size:	241.5 KB 
ID:	15596

    Here is the code I have but it doesn't work:
    Private Sub Category_DblClick(Cancel As Integer)

    Forms![Employees Form]![TrainingTopics subform].Form.Filter = "Category = " & Me.Category & ""
    Forms![Employees Form]![TrainingTopics subform].Form.FilterOn = True

    End Sub

    Any help would be greatly appreciated. Thank you!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    SubForms have a built-in filtering system with the LinkMaster/ChildFields properties of the SubFormControl. If you create an invisible TextBox with a control source that points to your Category field in the TrainingQry2 subform then you can set the MasterLinkField to point to the invisible Textbox and it will just work.

  3. #3
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Thanks RuralGuy but I can't get the text box to display the Category Name. I have the this: =Forms![TrainingQry2 subform]![Category].OnDblClick for the Control Source in the text box. When I double click on a category name in the TrainingQry2 subform, the text box doesn't display the name; it displays #Name? instead.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try: =[TrainingQry2 subform].FORM.Category

  5. #5
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Wow that works great. Thank you!

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Magical isn't it? Glad we could help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Clearing a subform filter
    By Fish218 in forum Forms
    Replies: 1
    Last Post: 03-28-2013, 02:25 PM
  2. Replies: 1
    Last Post: 08-16-2012, 01:51 PM
  3. Replies: 6
    Last Post: 05-05-2012, 08:43 AM
  4. Filter subform
    By DCV0204 in forum Forms
    Replies: 1
    Last Post: 12-01-2011, 10:37 AM
  5. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums