472,958 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Retrieve Filter value

Hi guys

I've got a report that I have created. It is based off of a query that I made. I use it to show different combinations of data, but its the same type of information...

It is called from 5 buttons on a form. each of the buttons opens the report to show something different, most are just the time frame of the data, whether it be 1 day, 1 week, 1 month, 1 year... Each one uses the doCmd.OpenReport method, and then passes a Where statement, so that the report opens with it's query based on the conditions passed. This all works fine for me.

What I would like to be able to do is an aesthetic thing. Since the report shows different time frames depending on the button, I would like for the title of the report that shows up to relate to the specific time frame.

From the research I've done, my Access 2000 does not allow me to pass openargs with openReport, so I cant go that route. I saw getOptions, but it doesn't look like I can pull the filter from that.

The only way that I can see to do what I want is to pull the Where clause that is passed (since that is the only thing differentiating one instance of the report from another), and parse that up to find it's contents, which will tell me the time frame. But I can't figure out how to pull the filter.

Does anybody know how to do that, or if it is possible?

thanks

Josh
Nov 9 '07 #1
5 2117
ADezii
8,834 Expert 8TB
Hi guys

I've got a report that I have created. It is based off of a query that I made. I use it to show different combinations of data, but its the same type of information...

It is called from 5 buttons on a form. each of the buttons opens the report to show something different, most are just the time frame of the data, whether it be 1 day, 1 week, 1 month, 1 year... Each one uses the doCmd.OpenReport method, and then passes a Where statement, so that the report opens with it's query based on the conditions passed. This all works fine for me.

What I would like to be able to do is an aesthetic thing. Since the report shows different time frames depending on the button, I would like for the title of the report that shows up to relate to the specific time frame.

From the research I've done, my Access 2000 does not allow me to pass openargs with openReport, so I cant go that route. I saw getOptions, but it doesn't look like I can pull the filter from that.

The only way that I can see to do what I want is to pull the Where clause that is passed (since that is the only thing differentiating one instance of the report from another), and parse that up to find it's contents, which will tell me the time frame. But I can't figure out how to pull the filter.

Does anybody know how to do that, or if it is possible?

thanks

Josh
It is definitely possible, and actually very simple:
  1. Create a 'Global' Variable to hold the String Value for the Time Frame.
    Expand|Select|Wrap|Line Numbers
    1. Public gstrTimeFrame As String
  2. For each Command Button, assign an appropriate value to this Global Variable, for instance the Monthly Time Frame.
    Expand|Select|Wrap|Line Numbers
    1. gstrTimeFrame = "Monthly"
    2. DoCmd.OpenReport "rptWhatever", acViewPreview
    3.  
  3. In your Report's Open() Event, assign the Caption of the Report based on the value of gstrTimeFrame.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Report_Open(Cancel As Integer)
    2.   DoCmd.Maximize
    3.   Me.Caption = "Time Frame (" & gstrTimeFrame & ")"
    4. End Sub
    5.  
    Sample Caption:
    Expand|Select|Wrap|Line Numbers
    1. Microsoft Access - [Time Frame - (Monthly)]
  4. Any questions, feel free to ask.
Nov 10 '07 #2
It is definitely possible, and actually very simple:
  1. Create a 'Global' Variable to hold the String Value for the Time Frame.
    Expand|Select|Wrap|Line Numbers
    1. Public gstrTimeFrame As String
  2. For each Command Button, assign an appropriate value to this Global Variable, for instance the Monthly Time Frame.
    Expand|Select|Wrap|Line Numbers
    1. gstrTimeFrame = "Monthly"
    2. DoCmd.OpenReport "rptWhatever", acViewPreview
    3.  
  3. In your Report's Open() Event, assign the Caption of the Report based on the value of gstrTimeFrame.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Report_Open(Cancel As Integer)
    2.   DoCmd.Maximize
    3.   Me.Caption = "Time Frame (" & gstrTimeFrame & ")"
    4. End Sub
    5.  
    Sample Caption:
    Expand|Select|Wrap|Line Numbers
    1. Microsoft Access - [Time Frame - (Monthly)]
  4. Any questions, feel free to ask.

That makes sense. It works, for changing the caption of the form. But is it possible to change a control on the report? I have tried changing labels and text boxes in the report_open function but it always gives an error that I can't assign a value to the object...maybe I can't do that with reports?
Nov 13 '07 #3
ADezii
8,834 Expert 8TB
That makes sense. It works, for changing the caption of the form. But is it possible to change a control on the report? I have tried changing labels and text boxes in the report_open function but it always gives an error that I can't assign a value to the object...maybe I can't do that with reports?
You are probably assigning it to the wrong Property of the Control, or to the Control itself. For instance, you can assign the Caption Property of both Labels in a Report to the Global Variable 'global var', but if you try to assign the global var to the [FirstName] Text Box you will generate the Error you describe, as in:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_Open(Cancel As Integer)
  2.   'will work fine
  3.   Me![PrimaryKey_Label].Caption = gGlobalvar
  4.   Me![tableheader].Caption = gGlobalvar      'Label Control
  5.  
  6.   'will generate the can't assign a value to the Object Error
  7.   Me![FirstName] = gGlobalvar
  8. End Sub
Nov 13 '07 #4
fantastic, works like a charm! thanks a lot for your help
Nov 14 '07 #5
ADezii
8,834 Expert 8TB
fantastic, works like a charm! thanks a lot for your help
Always glad to be of assistance here at TheScripts.
Nov 14 '07 #6

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

Similar topics

9
by: Robin Cull | last post by:
Imagine I have a dict looking something like this: myDict = {"key 1": , "key 2": , "key 3": , "key 4": } That is, a set of keys which have a variable length list of associated values after...
3
by: Richard | last post by:
Hi, I have a form based on a table. When I filter the form I want to run a report based on the same table with the same filter as the form. No problem until I want to filter a combo box where...
34
by: kevin.watters | last post by:
Hi all, I have a need for a short program: Given a drive letter, it would recursively search through all directories, "generating" each filename that it encounters (need to pass each filename...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
4
by: Rémy Samulski | last post by:
Dear readers, How can I obtain all AD Objects within a OU? I can find all AD Objects in the root of my Active Directory when I use the DirectorySearcher and passing the DirectoryEntry I find...
7
by: Peter | last post by:
Gday, I have a dataset with multiple tables, from which I want to access a single value in one of those tables. I know I can do something like: Decimal myVar =...
9
by: dee | last post by:
I'd like to filter by the following criteria: left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767 I have no idea how to do this. Appreciate help.
1
maxamis4
by: maxamis4 | last post by:
Hello folks, Here is the backgroup. I am creating an agent that can find a user in LDAP and return the last logon date. Now i am not sure if with active directory you can user the...
1
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...

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.