473,394 Members | 1,658 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,394 software developers and data experts.

Is there a way of showing the filter criteria in the cover page of a report?

LeighW
73 64KB
Hi all,

I'd like a cover page that shows which filter criteria have been used when creating the report. If this can't be done/ is very hard to implement then I'll leave it be but I thought it would be a nice touch.

So lets say I have in my table (tbl_1) with fields,

ID
Title
Description
Permit
Approval
Date

The report (rpt_1) is linked to tbl_1 and has all fields on it

And from a form (frm_Search) I apply a filter to the permit and approval fields which opens up the main form (frm_Main) filtered to the records with just permit = RSR and approval = true

So when I check the filter query on frm_Main it shows
Field = Permit Criteria = RSR
Field = Approval Criteria = True

I then open the report with:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "rpt_1", acViewPreview, , Me.Filter
How then could I show the filter criteria on the report?

If you need me to show how I created the filter I can provide it but I'm not sure how that would help in this instance.

Thanks for any help,

Leigh
Dec 13 '12 #1
9 4003
Rabbit
12,516 Expert Mod 8TB
You can use VBA to populate a label with the filter property in the OnLoad event of the report.
Dec 13 '12 #2
TheSmileyCoder
2,322 Expert Mod 2GB
As Rabbit says, the OnLoad event would be one way of doing it, it could look something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Load()
  2.    If Me.FilterOn Then
  3.       me.lblFilter.Caption=Me.Filter
  4.    End If
  5. End Sub
Dec 13 '12 #3
NeoPa
32,556 Expert Mod 16PB
Certainly up to Access 2003, Reports don't have the Load event :-( Nor are the .Filter or .OrderBy set up by the time the Open event fires. I recently had to handle this in one of my projects. The concept is clumsy, but works.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Activate()
  2.     Static blnRepeat As Boolean
  3.  
  4.     If blnRepeat Then Exit Sub
  5.     blnRepeat = True
  6.  
  7.     Me.lblTitle.Caption = Me.Filter
  8. End Sub
Typically, this will only ever run once at the start.
Dec 13 '12 #4
TheSmileyCoder
2,322 Expert Mod 2GB
Good point, I was not attentive to that fact. Newer versions of access has mixed the concept of Form and reports so they are alot more similar. I have yet to figure out exactly what was gained by this approach....

I think it might make more sense to use the reportHeader_Format event, but I haven't tested it.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
  2.    If Me.FilterOn Then
  3.       me.lblFilter.Caption=Me.Filter
  4.    End If
  5. End Sub
  6.  
NOTE: This will only work if the lblFilter is a control in the reportHeader.
Dec 13 '12 #5
NeoPa
32,556 Expert Mod 16PB
Smiley:
I think it might make more sense to use the reportHeader_Format event, but I haven't tested it.
Good thinking, mainly. Unfortunately, I don't believe this fires unless there is a Report Header section defined (at least). If you build reports consistently then this won't work for you (unless all your reports have Report Headers of course).

It does at least have the benefit of only ever firing once though, which is good in that respect.
Dec 13 '12 #6
LeighW
73 64KB
Thanks a lot guys,

I've annoyingly got Access 2003 so I haven't got the "On Load" event in the report.

I've tried both NeoPa's and Smiley's methods and for some reason Smiley's method refuses to fire while Neopa's does.

Now I have to work on changing the format to a more human view somehow so it doesn't show up like:
Expand|Select|Wrap|Line Numbers
  1. (([Permit = RSR) AND [Approval] = True)
But more like Permit = RSR, Approval = Yes

Could get a bit fiddly as there can be a number of different filters.
Dec 14 '12 #7
Rabbit
12,516 Expert Mod 8TB
You can use the replace function to get rid of the parentheses and change the AND to a comma.
Dec 14 '12 #8
NeoPa
32,556 Expert Mod 16PB
No surprise to see a clever suggestion from Rabbit. That may well be all you need.

Alternatively, if you need something more flowery, you can build the string in the form that calls the report and pass it as an OpenArgs parameter to the report. Generally, I would tend to go for a more simple solution like Rabbit's one if you can get away with that level of simplicity.
Dec 14 '12 #9
TheSmileyCoder
2,322 Expert Mod 2GB
As NeoPa pointed out my suggestion will only fire if the report has a (visible) report header. I presumed (my bad) that you had one, as to me that would be the logical place to display the filter used.

I shouldn't make assumptions without explicitly stating so.
Dec 14 '12 #10

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

Similar topics

4
by: Chris Geihsler | last post by:
I have a set of udf's dealing that return a one column table of values parsed from a comma delimeted string. For example: CREATE FUNCTION . ( @patient_list varchar(2000) ) RETURNS...
1
by: Andy V | last post by:
Hi. I've got a multi page report of my monthly purchases. I'd like a running total (month to date) at the end of each page and to have that total at the top of the following page. So far all I can...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
1
by: James Fortune | last post by:
In order to get the records I want on a report I sometimes create a SQL string for the RecordSource and sometimes supply the criteria using the Filter Property. If I use the Filter Property rather...
2
by: ME | last post by:
I need to know how to create a MULTI page report. All I can seem to create is a report with only one page, even though the datasource it is bound to returns multiple records. I have posted an...
2
by: tjdoss | last post by:
I am trying to display the "Filter by Form" criteria in a Report (that displays the filtered information). I have an unbound textbox with !. as the control source that will give me the Filter itself...
0
by: maxpirate | last post by:
I am trying to show list data from sub webs on the site collection. But when i try to set filter criteria some comparators like less than, greater than, less than or equal to and greater than or...
2
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few...
2
by: Charles Coleman | last post by:
I have several sub-reports in an Access report. All of the sub-reports use the same Query. I want to create a Filter so when the main report is opened, each sub-report shows is respective, (but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.