By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,056 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,056 IT Pros & Developers. It's quick & easy.

Apply Filter By Form to Report

Stang02GT
Expert 100+
P: 1,208
I have users who are using the Sort&Filter options on a from. Specifically they are using the Advanced>>Filter By Form option and then selecting a Vendor and applying that filter to the form.

After this Filter by form is applied they would like to be able to open the a report and have it only show the records they just filtered on.

We are using Access 2013, does anyone have suggestions on how we can accomplish this?
May 16 '17 #1

✓ answered by NeoPa

Hi Stang.

I'd do it slightly differently, using Me.Filter, but the results will be the same :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1680_Click()
  2.     Call DoCmd.OpenReport(ReportName:="Landscape Data Security Provision Review" _
  3.                         , View:=acViewReport _
  4.                         , WhereCondition:=Me.Filter)
  5. End Sub

Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,494
Use the .Filter property of the form in the call to open the report.
May 17 '17 #2

Stang02GT
Expert 100+
P: 1,208
So i could do something in the OnLoad Event of the report to reference the form filter?

or can i use the Filter On Load property on the report and set it to yes..but that leaves the question what do i reference in the Filter property on the report?
May 17 '17 #3

Stang02GT
Expert 100+
P: 1,208
Actually i figure it out.

I took the underlying query and changed it to have criteria on the vendor field that was looking at the form. So if they sort on the form and go to the report it will be based on what is currently on the report.
May 17 '17 #4

NeoPa
Expert Mod 15k+
P: 31,494
I assume somewhere you're using code to open the report. That would be in the format :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.OpenReport(...)
One of the parameters is called WhereCondition. Simply use the form's .Filter property in there.
May 17 '17 #5

NeoPa
Expert Mod 15k+
P: 31,494
Stang02GT:
Actually i figure it out.
...
I would recommend you steer clear of such interactions. They make the database objects incestuous in as much as they can only be used together and not flexibly anywhere in your database.

No such issues if the underlying object (QueryDef in this case.) has a filter applied externally.
May 17 '17 #6

Stang02GT
Expert 100+
P: 1,208
This is what i am using to try and accomplish what you are saying trying to work through it now.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1680_Click()
  2. Dim fltr As String
  3.     If Me.FilterOn Then fltr = Me.Filter
  4.     DoCmd.OpenReport "Data Security Provision Review",acViewReport , , ".Filter"
  5. End Sub
May 22 '17 #7

Stang02GT
Expert 100+
P: 1,208
This seems to be working well

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1680_Click()
  2.     DoCmd.OpenReport "Landscape Data Security Provision Review", acViewReport, , Form.Filter
  3. End Sub
Thanks for the direction on this Neo!
May 22 '17 #8

NeoPa
Expert Mod 15k+
P: 31,494
Hi Stang.

I'd do it slightly differently, using Me.Filter, but the results will be the same :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1680_Click()
  2.     Call DoCmd.OpenReport(ReportName:="Landscape Data Security Provision Review" _
  3.                         , View:=acViewReport _
  4.                         , WhereCondition:=Me.Filter)
  5. End Sub
May 22 '17 #9

Stang02GT
Expert 100+
P: 1,208
This was working great. Now i just got hit with something out the the blue. If you filter by form at the bottom of your form it displays a "OR" tab allowing you to filter the form for a different set of data.

When you apply the filter it brings all the results back to one form but this button i added is not applying the "OR" results to the report.

Would i need to apply multiple filters in this case?
May 22 '17 #10

NeoPa
Expert Mod 15k+
P: 31,494
Can you say what the state of Me.Filter is at the time - as well as what filtering you've applied to the form?

I don't filter by form on an existing form but I still can't see why it would resolve to anything different from what's stored in Me.Filter. Strange.
May 22 '17 #11

Stang02GT
Expert 100+
P: 1,208
So this issue is actually with the report. The filtering is working as expected.

I needed to remove some code from the report that i had forgotten about that was causing me issues.

Working great now. Thanks again!
May 23 '17 #12

NeoPa
Expert Mod 15k+
P: 31,494
8-) Pleased to hear it's all going well now :-)
May 25 '17 #13

Post your reply

Sign in to post your reply or Sign up for a free account.