Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data range parameter question 1

Status
Not open for further replies.

Oona8

Technical User
Apr 3, 2002
25
FR
Hi

I'm using CR 8.0
I have a report with several subreports and I would like it to show me values included in a date range. The values should be within yesterday 5.00 pm and today 5.00 pm.
I think I need a parameter to do this, but how? I've created 2 variables to get the begin and end dates, ie

@yesterday:

WhilePrintingRecords;
DateTimeVar yesterday;
yesterday:= DateTime(Year(CurrentDate),Month(CurrentDate),Day(CurrentDate-1),17,00,00);

@today

WhilePrintingRecords;
DateTimeVar today;
today:= DateTime(Year(CurrentDate),Month(CurrentDate),Day(CurrentDate),17,00,00);

How do I get the report to show the values in this date range, and the subreports as well?

Thanks

Oona
 
Hi Oona,

Have you tried using shared variables for your report and subreports. They can be used by the main report and all subreports. Below is an example of a shared variable:

// set SharedBudgetAcctTotal field to be used in
// subreport.
Shared CurrencyVar SharedAcctBudgetTotal;
SharedAcctBudgetTotal:= Sum ({@BudgetAmt},{ESXACCTR.ACCT_NO})

In the subreport(s) create a formula that declares the shared variables:

// Shared variable SharedAcctBudgetTotal field from
// main report.
Shared CurrencyVar SharedAcctBudgetTotal;
SharedAcctBudgetTotal

hope this helps!
bill
 
Hey,
If I understand you correctly that you should make your main report accept those two variables you created as parameters within your SQL Statement in the WHERE clause and the same for all your sub-reports. In other words, in crystal, go to menu Report, pick edit selection formula -> record, enter 'whatever field that accepts the date here' >= @yesterday AND 'whatever field that accepts the date here' <= @today. I believe you could pass these variables to your sub-reports either the same way or through the Sub-Report links in the Edit menu..I'm not 100% which to but I'm pretty sure you can accomplish this by using the sub-report link.
I tested the first part of this so, it should work for you too. Hope this helps.


 
You pretty much have it, except you don't want to ever use variables in something that will be used in the record selection (Report->Edit Selection Formula->Record), as this prevents the SQL from being passed to the database which hinders performance.

(
MyTable.MyDate >= DateTime(Year(CurrentDate),Month(CurrentDate),Day(CurrentDate-1),17,00,00)
and
{MyTable.MyDate} <= DateTime(Year(CurrentDate),Month(CurrentDate),Day(CurrentDate),17,00,00)
)

-k kai@informeddatadecisions.com
 
Thanks very much to all of you guys, synapsevampire's solution worked very well

Cheers

Oona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top