Skip to Content

Default parameters in Crystal Report

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Aug 01, 2017 at 05:50 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Aug 01, 2017 at 08:50 AM

    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

    Add comment
    10|10000 characters needed 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.

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

    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

    Add comment
    10|10000 characters needed characters exceeded