473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Apply Filter By Form to Report

Stang02GT
1,208 Expert 1GB
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

12 2587
NeoPa
32,556 Expert Mod 16PB
Use the .Filter property of the form in the call to open the report.
May 17 '17 #2
Stang02GT
1,208 Expert 1GB
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
1,208 Expert 1GB
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
32,556 Expert Mod 16PB
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
32,556 Expert Mod 16PB
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
1,208 Expert 1GB
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
1,208 Expert 1GB
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
32,556 Expert Mod 16PB
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
1,208 Expert 1GB
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
32,556 Expert Mod 16PB
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
1,208 Expert 1GB
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
32,556 Expert Mod 16PB
8-) Pleased to hear it's all going well now :-)
May 25 '17 #13

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

Similar topics

1
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
3
by: mattscho | last post by:
Hi All, Trying to create a set of 3 buttons in a form that have the same effect as the "Filter by Form", "Apply Filter" and "Remove Filter" Buttons on the access toolbar. Help would be muchly...
1
by: mattscho | last post by:
Re: Filter By From, Apply Filter, Remove Filter Buttons in a Form. -------------------------------------------------------------------------------- Hi All, Trying to create a set of 3 buttons in...
3
by: Supermansteel | last post by:
I am trying to run a Apply filter for everytime someone opens Form_CC it will only show the Test (Test_ID) they are working on. This seems to be the closest I have gotten to filtering it correctly,...
1
by: eHaak | last post by:
A couple years ago, I built a database in MS Access 2003. I built the form using macros in some of the command buttons, and now I’m trying to eliminate the macros and just use visual basic code. ...
3
by: dbdb | last post by:
hi guys need your suggestion how can i apply filter for my date variable data type i have a form name transaction and i have a text box on it named : start and finish i need to apply...
10
by: dbdb | last post by:
Hi, i create a chart in ms access based on my query, then i want my chart when is it open is only show value based on my criteria. i'll try to used it in the properties apply filter using the...
1
by: Azriel928 | last post by:
I know this is a simple function to program, but I'm a little rusty. I'm trying to set the "On Open" event on a report using a macro to apply a filter that I have saved as a query. Can you please...
1
by: Joe Martin | last post by:
I have a single report with several stats for each line. I would like the user to be able to apply one filter and then be able to apply a second filter to the same report. I have several buttons...
2
by: ka2015 | last post by:
Good day I'm Trying to apply filter in Macros in Microsoft Access 2007 but I failed in typing (where condition) in Macros. I want to create a split form with a search text box above actually...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.