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 & "'"
peterslove53Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul Cook-GilesSenior Application 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peterslove53Author Commented:
Figured out another route. Just making a split form and hiding the display region solves it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.