cancel
Showing results for 
Search instead for 
Did you mean: 

Default parameters in Crystal Report

Former Member
0 Kudos

Hi all,

I am trying to create date default parameter be the first and last day of the previous month in Crystal Report XI to pull data automatically for the full previous month. Any advice would be greatly appreciated. Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

IIRC, XI r2 did not have the capability of setting default values for parameters or for making parameters optional. Does your report need to have parameters a user can enter or will the dates always be for the previous month?

If you do not need to have user-entered parameters, you can use {date field} InLastFullMonth in the selection formula to automatically give you the previous month's data.

Ian's suggestion for using a command is another way to do this. See this blog post for information about best practices for using commands - there's a lot of info in it about how to work with parameters in commands.

-Dell

Former Member
0 Kudos

Thank you Dell. I am new to Crystal Report and I do not have experience with using commands. I had thought there is a formula I can use.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Alisia, I'm guessing you don't have a crystal reports server and therefore no repository. The old way was to add the

cdFirstDayOfMonth and cdLastDayOfMonth from the Repository Custom Functions to your report then reference this in your formula as

cdFirstDayOfMonth(DateAdd("m",-1,CurrentDate) to cdLastDayOfMonth(DateAdd("m",-1,CurrentDate)

You can try using DateAdd("m",-1,DateAdd("d", -Day(CurrentDate),CurrentDate))+1 to DateAdd("d", -Day(CurrentDate),CurrentDate)

- Rob

Former Member
0 Kudos

Thank you Robert!

Former Member
0 Kudos

Is this for a scheduled report or to speed up users data entry.

If report is based on a command you can add Variables to the report whereby if Parameter has a default value the variable are assigned the values you want.

Syntax depends on database.

Ian

Former Member
0 Kudos

Many thanks for the prompt reply. Yes, this report need to be scheduled through web portal. I was wondering if there any formula I can use in Record Selection. Thanks again.