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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data from sub-report with yesterday's Date

Status
Not open for further replies.

pleashelp

Technical User
Feb 27, 2002
97
US
I have a report that has 2 parameters: ?StartDate and
?EndDate. I have a subreport linked to the report on the dates.
In the main report, my selection criteria is :{Day_Meter.dtBusDay} in ({?StartDate}-1) to {?End Date} so that I can possibly get data from the previous day also. This part works fine in the main report. I am able to pull data with a formula like this:

if {Day_Meter.dtBusDay}in[({?StartDate}-1)to({?End Date}-1)]
then {Day_Meter.iStackerAmount}/100 else 0

Now I need to get data from the sub-report. I have my selection criteria set at:
{Liability.dtBusDay} in {?Pm-?StartDate} to {?Pm-?End Date}

I have a formula to get data from yesterday's business day:

if {Liability.dtBusDay}>= ({?Pm-?StartDate}-1)
and {Liability.dtBusDay}< ({?Pm-?End Date}-1)
then {Liability.iFinalTicketLiabCents}/100

My result is a zero, and I know that there should be a number there.

What am I doing wrong?

Thanks
 
First, adjust the record selection formula in the subreport to match the main report.

Right click the subreport and select Edit Subreport

Select Report->Edit Selection Formula->Record and change it to:

{Liability.dtBusDay} in ({?Pm-?StartDate}-1) to {?Pm-?End Date}

Now make sure that your formulas make sense, in the main you use:

if {Day_Meter.dtBusDay}in[({?StartDate}-1)to({?End Date}-1)]
then {Day_Meter.iStackerAmount}/100 else 0

Which really only limits the end date to 1 less than the rows that are in the report. Is this what you really need? If so, why don't you just change the record selection formula to be -1 against each day, or eliminate the redundant date checking?

In the subreport formula you do the same thing, again, this seems wrong:

if {Liability.dtBusDay}>= ({?Pm-?StartDate}-1)
and {Liability.dtBusDay}< ({?Pm-?End Date}-1)
then {Liability.iFinalTicketLiabCents}/100

Note that it is not a <= on the end date here, it's just <, which may be also contributing to your bad data.

Perhaps you misunderstand what the record selection formula does, it limits the rows in the report. So checking for {Liability.dtBusDay}>= ({?Pm-?StartDate}-1) is redundant as you've already filtered them out at the report level (record selection formula) using the record selection formula.

Hope this helps to clarify.

-k
 
In regards to the date selection in the main report, I want to be able to pick up the previous day's data for some fields in relation to the date that is entered in the parameters. So the client enters 6/30 to 7/1, which works for most of the fields. But a couple of fields need the previous day's data. Therefore, the -1 in the start date, so that it will select those rows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top