0
votes

I'm working with SQL Server Reporting Services 2005.

I have a report with a dataset that gets data from a SQL Server database. Also, I have two report parameters of type DateTime (StartDate_param and EndDate_param) which the user selects on the report.

I have set a restriction if the user picks dates with different months, for example june 1 and may 3, the process stops:

I have this code on the Report Properties-----Code section to manage the restriction:

Public Function ValidateDate(StartDate As DateTime, EndDate As DateTime) As DateTime

  If (DateDiff(DateInterval.Month, StartDate, EndDate) <> 0) Then

      Err.Raise(6,Report)

  End If

End Function

and I have set a hidden parameter CheckDateRange which calls the ValidateDate function with this expression:

= Code.ValidateDate(Parameters!StartDate_param .Value, Parameters!EndDate_param .Value)

This stops the SQL processing and i get this error when entering dates with different months:

Error during processing of 'CheckDateRange' report parameter

But I would like to show a message on a Textbox instead of the message that's showing now, how can I do that?

if that is not possible, what could I do in that case?.

thanks..

1

1 Answers

1
votes

What about instead of stopping the process, just show a different 'report' to the user. This error report would have the error message that you would want to show the user. You would then just set the conditional visibility of the reports depending on the evaluation of the parameters, you could also alter the SQL of your 'actual' report so that it doesn't even run when the error parameters are given by the user (this would prevent making a now useless query because this data won't be shown).

So if your report now is a tablix set the tablix's visibility condiiton to hide when the error parameters are given. Then create a text box outside that tablix that will store your error message and give it the opposite visibility condition logic. Then alter the SQL query so that it just returns a null row when the error params are given.