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

Default parameter

Status
Not open for further replies.

swhitt

MIS
Aug 27, 2003
28
US
I have a parameter for run date range in my report. I want the user to be able to enter a specific date range, however I want it to default to current date - 1. The date I'm using is "ACTDTTM". I have tried this with no success:
if {?Run Date Range} <> {?Run Date Range} then
{INTERFACE_LOG.ACTDTTM} = CurrentDate - 1

Can someone please help? Thank you in advance.
 
Parameters won't default to a calculated value, however you can set a default value and use that to create a calculated default.

In the parameter editor, select set default value and enter something that would never be used, such as 1/1/1950

Then in the record selection formula, use something like:

(
if {?Run Date Range} <> cdate(1,1,1950) then
{INTERFACE_LOG.ACTDTTM} = {?Run Date Range}
else if {?Run Date Range} = cdate(1,1,1950) then
{INTERFACE_LOG.ACTDTTM} = CurrentDate - 1
)

If the user leaves the default, it will use yesterday, otherwise it will use whatever is entered.

Note that the record selection is designed this way to try to assure SQL pass through.

-k
 
Thank you for your reply, however right after I submitted the post I was able to get my formula to work. The formula works as designed, it uses yesterday as the run date if nothing is entered, however it displays today's date. How do I get it to display yesterday's date in the parameter value box?
 
That was the point of setting a default, you can't change it in the box.

You're telling me that the following worked?:

If {?Run Date Range} <> {?Run Date Range} then
{INTERFACE_LOG.ACTDTTM} = CurrentDate - 1

Makes no sense to me...

Also make sure that you check the Database->Show SQL Query to make sure that what you've coded is passed to the database, if not performance will suffer.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top