Ticket Q230789
Visible to All Users

how do I set a default date parameter to 1 month prior to the current day's date?

created 16 years ago

I'm migrating from Sql Server Reporting Services to XtraReports. In reporting services .RDL once could set a date default value based on a formula, such as this:
=DateSerial(Year(DateAdd(DateInterval.Month, -1, Now)),Month(DateAdd(DateInterval.Month, -1, Now)), 1)
(see the attachment for where that would be setup in the RDL gui)
How can I setup the comperable default value in XtraReports?

Comments (3)
DevExpress Support Team 16 years ago

    Hi Greg,
    With the XtraReport suite you can use the ParametersRequestBeforeShow event to adjust the value.
    For example :
            private void XtraReport1_ParametersRequestBeforeShow(object sender, DevExpress.XtraReports.Parameters.ParametersRequestEventArgs e) {
                e.ParametersInformation[0].Parameter.Value = 30;
            }
    Please try this solution and let us know the results.
    Thanks,
    Andrew

      This didn't work… it didn't provide any values into the parameters screen when previewing the report. I've attached a screenshot. It just has default dates with the year 0001.
      Here's the code:
          Private Sub TransactionBlotter_ParametersRequestBeforeShow(ByVal sender As Object, ByVal e As DevExpress.XtraReports.Parameters.ParametersRequestEventArgs)
              e.ParametersInformation(0).Parameter.Value = DateTime.Now()
              e.ParametersInformation(1).Parameter.Value = DateTime.Now()
          End Sub
      Greg

      DevExpress Support Team 16 years ago

        Hi Greg,
        Are you referring to the situation when you preview a report in Visual Studio? Note, that the report's code-behind (including the ParametersRequestBeforeShow event handler) isn't effective in this situation. This code will be executed when displaying the report's Preview mode at runtime only. If you need to see changes both at design time and at runtime, please use the XtraReports' Scriptingtechnology, and move the ParametersRequestBeforeShow event handler to scripts (see the XtraReport -> Scripts collection in the Property Grid).
        Thanks,
        Alex

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.