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!

Using Record Selection with Parameter Fields

Status
Not open for further replies.

englandgreen

IS-IT--Management
Mar 27, 2012
3
GB
I'm fairly new to Crystal reporting (Using Crystal Reports 2008).
I have used some parameter fields in the some reports, but there are some things I can't find a solution to.

I have been asked to generate some reports that have been missed in the last few months & also generate reports that will allow people to select a period for the report.

My issue comes when the report uses something like this for the Record Selection Forumla:

{XJOBS.XX_DATE} in LastFullMonth

This only gives me the last full month from when the report was run not from a date I want to put in. I have a parameter, say {?Activity Period}, that I want to use. Somthing that would allow me to run the report, be asked for a date and be able to calculate the last full month as if I was running the report at that time/date.

So combining {XJOBS.XX_DATE} in LastFullMonth & {?Activity Period}
 
Make ActivityPeriod a Date parameter, and then set it to be a Range, then if you just want the data in that period it's

{XJOBS.XX_DATE} IN {?ActivityPeriod}

if you still need the last month, it's

{XJOBS.XX_DATE} IN LastFullMonth OR
{XJOBS.XX_DATE} IN {?ActivityPeriod}
 
{?Activity Period} is set to be a Date parameter but it's a single date.
I want to know if it's possible to use the LastFullMonth formula to work back from my {?Activity Period} parameter, or do I need to set 2 parameters {?Activity Period Start} & {Activity Period End} i.e.

{XJOBS.XX_DATE} IN {?Activity Period Start} to {?Activity Period End}

or set {?Activity Period} to a Range & use:

{XJOBS.XX_DATE} IN {?Activity Period}

I really wanted to be able to setup the reports so that someone could select any day in any month & it would run the report as if it was run on that day. Having users make sure they have selected the 1st & last day of the month in either of the above options may create incorrect results in the final report..... as it's all too easy for a user to put in the wrong parameters & still generate a report

 
You could just use a formula like this:

{XJOBS.XX_DATE} in date(year({?Date}),month({?Date}),1) to
dateserial(year({?Date}),month({?Date})+1,1)-1

You would be instructing the user to pick any date in the month that they would like to report on.

-LB
 
I think englandgreen is asking that the user can select a range (e.g. Jan 2012) and the report which is normally based on lastfullmonth can be ran to look at the date range specific instead of just the last full month.

Rather than the selection criteria it is the other component parts of the report that are the issue.

As for a solution, you need to review all formulae / selection criteria / totals & suppression etc within your report and wherever it currently mentions lastfullmonth change it to instead reference your new parameter date range.

Replace any mention of lastfullmonth with {?ActivityPeriod}.

For example, your selection criteria would become:
{XJOBS.XX_DATE} in {?Activity Period}

A formula to display the user selected date range as a title might become:

'Report period: ' + minimum({?Activity Period}) + ' to ' + maximum({?Activity Period})

If you then need to further restrict or adjust the report so that the user is forced to only selectsa specific month/year instead of date range then this too can be implented but we need a bit more clarification from you first if possible.

'J

CR8.5 / CRXI - Discovering the impossible
 
Thank you very much for the replies.

In this instance I wanted the user to be able to specify a day for the report to be run on. The case being that they may have missed some previous reports & although it is relevant to a previous month, the solution provided by lbass:

{XJOBS.XX_DATE} in date(year({?Date}),month({?Date}),1) to
dateserial(year({?Date}),month({?Date})+1,1)-1

works perfectly in this case

A lot of the reports that are setup to run were relevant to the parameter "today", so it was simple enough to ask the user for the day to run the report on. Ibass's formula enabled me to do the same thing with the monthly reports that were generated on any given day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top