• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

How do i open a subform to a filtered record from another form

I am trying to open a subform to a specific filtered record (ID = ID from anotherform)
but i am not getting any filtered records even when i use the syntax below.
where "NotesAssignment" is the form having the subform i want filtered.

the two forms (mainform and NotesAssignment) have a common field (report_id and Ext_rept_urn )


DoCmd.OpenForm "NotesAssignment", acNormal, , "report_id='" & Ext_rept_urn & "'"
0
peterslove53
Asked:
peterslove53
  • 2
1 Solution
 
Paul Cook-GilesAccess/VBA/SQL Database DeveloperCommented:
Peter, is the subform an object on your main form? How are you executing the filter code?

The code below will toggle between displaying filtered data and unfiltered data on a subform (and incidentally change the caption on the button that applies/removes the filter).  It uses a literal for filtering, but you can easily swap in your code using a variable.  Let me know if this needs more explanation.  :)

PCG


<><>
If Me.btnFilterAdv.Caption = "Show Adv" Then 'records are unfiltered
        Me.RevenuePreparationSubFrm.Form.Filter = "[Revenue Type] like '*adv*'"
        Me.RevenuePreparationSubFrm.Form.FilterOn = True
        Me.RevenuePreparationSubFrm.Requery
   Me.btnFilterAdv.Caption = "Remove Filter"
Else
   'Me.RevenuePreparationSubFrm.Form.Filter = "[Revenue Type] like '*adv*'"
        Me.RevenuePreparationSubFrm.Form.FilterOn = False
        Me.RevenuePreparationSubFrm.Requery
   Me.btnFilterAdv.Caption = "Show Adv"
End If
<><>
0
 
peterslove53Author Commented:
I have two forms. ('NotesAssignment'  and 'MainForm')
The NotesAssignment is built to have a subform as the only form. From the main form, i will like to pass the ID parameter to the subform when a command button on the main form is clicked henced filtering the subform on NotesAssignment using the passed parameter from the mainform.

I am not sure how that will accomplish this task
0
 
peterslove53Author Commented:
Figured out another route. Just making a split form and hiding the display region solves it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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