Is it possible to create a server side or client side validation for parameter inputs For example, I want a calender input to error when a user tries to put in a date past the current date time
Is it possible to create a server side or client side validation for parameter inputs For example, I want a calender input to error when a user tries to put in a date past the current date time
Parameter validation
Brennon
Yes!
You need to add a function to validate the parameters.
Go to the Report Properties under the Report menu and place this code to the Code Tab.
Function CheckSignificantDate(StartDate as Date, EndDate as Date) as Integer
Dim msg as String
msg = ""
If (StartDate > EndDate) Then
msg="Start Date should not be later than End Date"
End If
If msg <> "" Then
MsgBox(msg, 16, "Report Validation")
Err.Raise(6,Report) 'Raise an overflow
End If
End Function
Then go to the Report Parameters and Add named it Validate with the datatype is string. Checked the Hidden and Allow blank value ckeckboxes. In Available Values choose Non-Queried and from Default Values choose Non-Queried in right side of textbox then press the FX button then paste this code.
=CODE.CheckSignificantDate(<parameterStartdate>.Value,<parameterEnddate>.Value)
Then press OK.
Cedric509
Hi Gil,
Its working,It is displaying the message box but Report generation is not stopped.Report is generating but displaying no data.What i have to do is display the message box containing startdate should not be later than enddate,and user enter tha dates again, stop the report rendering
How to handle this
Please help me.
Thanks in advance
GSReddy
Hi,
I think the error is displaying because of the line "Err.Raise()", If we remove this line It is working fine.But if we remove that there is no meaning.
Thanks
renemt
Please try using the below solution it helped me to solve similar issue.
1) Add a TextBox to the Report.
2) In the Value Field for the TextBox add the below value
=IIF(Parameters!FromDateTime.Value>Parameters!ToDateTime.Value Or Parameters!ToDateTime.Value < Parameters!FromDateTime.Value,"Invalid Date Parameters Supplied, Please Check the Date Parameter Values","No Data is Available for the Selected Date Range between " & Parameters!FromDateTime.Value & " and " & Parameters!ToDateTime.Value & ".")
3) In its Visibility Property Hidden value add the below Code.
=IIF(CountRows("CCFReportDS")>0,True,False)
TheMaj0r
Hi,
even I am facing same problem, where I am also getting same error called "error in processing 'Validate' parameter."
did you got any solution.
If yes please share the solution with me.
thanks,
Ramesh KS
Al Harlow
Problem with these all above solution is
It first show Error Message and then got to database.
Is there any solution that can be only client side validation instead of database round trip
AppSpecialist
Hi,
I did like that,but popup i displaying but in the report server iam getting error,error in processing 'Validate' parameter.
Thanks in advance
Helan
Hi,
I am using the function called "CheckSignificantDate" which is mentioned below.
This is my current situation
report can works in the report designer (in preview),but it doesn't work on the server after i deployed it to the server.deploy successfully,why does it give me the message that is Error during processing of 'fromYear' report parameter.(rsReportParameterProcessingError).
do I need to do anything with custom assemblies
or any other reasons this
Regards,
Ramesh KS
function which I used:
Function CheckSignificantDate(ByVal StartDate As Date, ByVal EndDate As Date) As Integer
Dim msg As String
msg = ""
If (StartDate > EndDate) Then
msg = "Start Date should not be later than End Date"
End If
If msg <> "" Then
MsgBox(msg, 16, "Report Validation")
Return 0
End If
Return 0
End Function
Anthony Sneed
AlexBB
This is great, is there anyway to integrate this with making a error message visible on the report and not through a popup message box
Thanks for the solution.
spattewar
Yes!
All you have to do is delete the Validate Parameter that you add from the Report Parameter and the Codes that you paste from the Report Properties.
Then into your form. drag a Rectangle from the toolbox. Set the Border Color to red (this is the standard for an error message, in case you are not familiar) =D. Just kidding. Drag a texbox into your rectangle place the message "Date From should not be later than Date To.". Into the Rectangle properties, go to the Hidden properties under the Visibility property of the rectangle then add this expression:
=IIF(Parameters!StartDate.Value > Parameters!EndDate.Value,
false,true)You can now test your report.
Note: Applies only in the Body of the report.
Anupama
Hi mahimam,
I think you forgot to do this.
Go to the Report Parameters and Add named it Validate with the datatype is string. Checked the Hidden and Allow blank value ckeckboxes. In Available Values choose Non-Queried and from Default Values choose Non-Queried in right side of textbox then press the FX button then paste this code.
=CODE.CheckSignificantDate(<parameterStartdate>.Value,<parameterEnddate>.Value)
Report generation should stop because you already set the parameters to the report properties once you click the view report button.
soconne
Hi,
It sounds like a custom ASP.NET page might be a better solution. You would have complete flexibility to provide validation messages to the user and could render the report by calling the Render() method of the ReportServiceExecution2005 class.
Hope this helps,
Bill