Solved

Have criteria in report header?

Posted on 2000-03-06
7
216 Views
Last Modified: 2009-12-16
When we run a report it asks for two dates (start and finish), how can we have these show in the report header?
0
Comment
Question by:treyjeff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Accepted Solution

by:
blakeh1 earned 5 total points
ID: 2588943
Your best bet would be to declare the parameters in the query. Under the Query Menu choose, paramters, enter in the values. After this add a field for each parameter to the grid as new fields. then you can just add them directly from the field list in design view for the report.
0
 

Expert Comment

by:rpm97
ID: 2589198
Another way would be to create a form with two unbound text boxes, one for beginning date (beginningdate_txt) and one for endingdate (endingdate_txt).  Then in the criteria section of the your query for the date on which you are running your report, enter "between forms!yourform!beginningdate_txt and forms!yourform!endingdate_txt" (without the quotes).

When running the report, you can set yourform.visible = false, and add the fields into your report the same way as in the criteria in the query (forms!yourform!beginningdate_txt and forms!yourform!endingdate_txt)

0
 
LVL 7

Expert Comment

by:Believer
ID: 2589340
A third option...
I have grown *very* fond of putting report parameters into a local work table.  Then I tie the table into the query used by the report.  Voila!  No more Forms!Formname!FieldName...
Can also run reports *without* having the form open.
Here's a work table, tblOptions, for your specific situation (e.g. from/to date parameters):
bytWork is a byte field with:
  default value 0 (zero),
  validation rule"=0",
  Required=Yes,
  Indexed=Yes (No Duplicates)
datFrom is a date field
datTo is a date field

bytWork is only in the table to make sure that only one record ever gets put into the table.

Go into the query that your report is based on and add tblOptions to it.  Do not link this table to any other table in the query.  Add the fields [datFrom] and [datTo] to the query grid.  On the criteria row for the date field used by your report, type:
  Between [datFrom] And [datTo]

In your report, [datFrom] and [datTo] will now be available as normal fields that you can drop in the report header.

Side note: If your query happens to already have multiple tables and any of them are joined with arrows (Left outer join, etc.) then you will get an error when you run this.  To solve that problem, don't put tblOptions in the query.  Instead, define a NEW query which contains tblOptions and the original query.  Drag all the fields to the grid from your original query and tblOptions.  Add the "Between" criteria as described above.  To get these dates to show up in your report header, put them all by themselves in a subReport based solely on tblOptions.

Now for the user interface which runs the report... Bind the form to tblOptions and drop the fields on the form.  Add a buton to open the report.  In the code behind the button, *before* you run the report, DoCmd.RunCommand acCmdSaveRecord.  That will force access to save the dates to tblOptions before the report runs.

<Whew.>  I think I covered everything.  If not, I'm sure I'll hear about it! (lol)  This may sound like a bit of work, but it really ain't that bad.  It makes overall application design a lot easier!  You won's miss those "Forms!Formname!FieldName..." expressions a bit, I promise!!

0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:treyjeff
ID: 2589452
Well in our query we have it set under query to ask for start date and finish date :)  I just want the easiest way :)
0
 
LVL 7

Expert Comment

by:Believer
ID: 2589471
treyjeff,
I'm all for easy, too, but I'm also for nice-to-the-user.  (I'm not trying to be mean to you, I promise!)
Another cool side-effect is that the criteria the user enters are saved.  Next time the report prompt opens, they can see the values they used last time.
0
 
LVL 7

Expert Comment

by:Believer
ID: 2589496
A couple more general comments about using this method...

First off, this method is *not* well-suited to a front-end that is run by multiple users.  By that I mean if several people have shortcuts to the (front-end) database running on a network.  Each user's change to the report parameters can affect the other users.  If you install a separate font-end on each user's machine then you will have no problem.

Next, if you are doing a different kind of parameter this gets even easier.  Let's use "Customer" as an example...  If you have a table of customers (tblCustomers), add the customer field, lngCustomerID, to tblOptions and make it a combo box on the report prompt form (assuming that you have a customer lookup table, of course).  Now when you add tblOptions to the report's query, link [tblOptions].[lngCustomerID] to [tblCustomers].[cntCustomerID].  The query is now customer-specific... no query criteria!  Only records where [tblOptions].[lngCustomerID] match [tblCustomers].[cntCustomerID] will be included in the recordset.

That's all I can think of for now...
0
 
LVL 1

Author Comment

by:treyjeff
ID: 2597744
It worked :)
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question