Skip to Content
0

Default parameters in Crystal Report

Jul 31, 2017 at 11:02 PM

81

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Dell Stinnett-Christy Aug 01, 2017 at 05:50 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
Ian Waterman Aug 01, 2017 at 08:50 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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.

0
avatar image
Former Member Aug 03, 2017 at 10:06 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thank you Robert!

0