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!

Default Date Parameters in CE 1

Status
Not open for further replies.

farside11

MIS
Nov 10, 2003
12
AU
Hi there,

I am having trouble running reports from CE 10 which needs to run automatically for the previous day. In CR, when running a report with a date parameter, the parameter defaults to the CurrentDate. This makes it easy to create conditional Record Selection, such as "if {?Date} = CurrentDate then {DateField} = CurrentDate-1 else...".

However, trying a similar strategy in CE doesn't work. The report fails immediately if a parameter isn't specifically set, complaning that CE "needs more information".

Is there a technique in CE to automatically have the date parameter set to equal CurrentDate? I hope I'm overlooking the obvious!

Many thanks,

 
I typically handle this by having some defaults in my paramater, and then checking the parameter at in the Record Selection formula.

I typically do this 2 different ways. I either use one string paramter with some values like "Yesterday", "Last Week", "Last Month", etc. I then check the values in the Record Selectin:

{table.date} in
switch
(
{?Period}="Yesterday",currentdate - 1,
{?Period}="Last Week",lastfullweek,
{?Period}="Last Month",lastfullmonth
)

In Crystal Enterprise, you would pick the appropriate parameter value to get the timeframe you want. This also works really well for scheduling.

The second option is very similar, but uses 2 parameters and allows for a date override if the user selects a particular value.

So, create 1 string paramter with some defautls like "Yesterday", "Today", "Tomorrow", and "Custom", and then 1 date parameter that they should populate if they choose Custom from the first parameter.

In you selection criteria, do this:

{table.date} =
switch
(
{?Period}="Yesterday",currentdate - 1,
{?Period}="Today",currentdate,
{?Period}="Tomorrow",currentdate + 1,
{?Period}="Custom",{?Custom Date}
)

Again, this works in CE the same way as the first option, but if they pick Custom from the first paramater, it will expect a value from the second paramter.

~Brian
 
Thanks Brian,

I guess that's the path I would have headed, but your technique provides a real elegant solution... not to mention one that could be standardised over the whole suite of reports.

Many thanks! And what a swift reply! Thanks Tek-Tips for a terrific forum!!

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top