locked
How to display a message when the parameter value is not provided in correct format? RRS feed

  • Question

  • I have a simple report with one parameter Year. The format is YYYY-YYYY.

    If a user enters a wrong year then the report should not render and instead it should show a message to enter the given format or correct year.

    Scenarios when user enters the wrong value might occur like this,  

    1) 201-2015 instead of 2014-2015

    2) 2 instead of 2014-2015

    3) 2012-2013 which is the wrong year (Since I have YEAR > '2014-2015' in Where clause)

    Wrong input Example:

    How do I implement this?

    Appreciate your help. Thanks!

    Monday, February 20, 2017 8:19 PM

Answers

  • Hi NewMSSAS,

    So, what's the query looks like in your dataset?

    As far I know, we can not customize error message when the parameters format is not correct, and judge the format of parameters value is difficult in SSRS. Based on my test, it seems that a workaround that we can add a text above your tablix and display the error message and control the visibility based on the condition. Please refer to following steps:

    1. Sample data.

    2. Query in the dataset.

    select * from test17022102 where year >@year

    3. Control the visibility of error message.

    
    
    =IIF(Parameters!year.Value<=2014 and len(Parameters!year.Value)<>4,false,true)

    4. Control the visibility of the tablix.

    =IIF(Parameters!year.Value>2014 and len(Parameters!year.Value)=4,false,true)

    5. Test.

    The sample is simple and the condition is not comprehensive, but this workaround that you can refer to.

    Hope this helps.

    Best Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Pirlo Zhang Monday, February 27, 2017 1:35 PM
    • Marked as answer by NewMSSAS Tuesday, March 7, 2017 4:46 PM
    Tuesday, February 21, 2017 6:47 AM

All replies

  • Hi NewMSSAS,

    So, what's the query looks like in your dataset?

    As far I know, we can not customize error message when the parameters format is not correct, and judge the format of parameters value is difficult in SSRS. Based on my test, it seems that a workaround that we can add a text above your tablix and display the error message and control the visibility based on the condition. Please refer to following steps:

    1. Sample data.

    2. Query in the dataset.

    select * from test17022102 where year >@year

    3. Control the visibility of error message.

    
    
    =IIF(Parameters!year.Value<=2014 and len(Parameters!year.Value)<>4,false,true)

    4. Control the visibility of the tablix.

    =IIF(Parameters!year.Value>2014 and len(Parameters!year.Value)=4,false,true)

    5. Test.

    The sample is simple and the condition is not comprehensive, but this workaround that you can refer to.

    Hope this helps.

    Best Regards,

    Pirlo Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Pirlo Zhang Monday, February 27, 2017 1:35 PM
    • Marked as answer by NewMSSAS Tuesday, March 7, 2017 4:46 PM
    Tuesday, February 21, 2017 6:47 AM
  • Thank you Pirlo. 

    I used your recommendation and it worked fine. I added a text above the tablix and displayed the error message.

    Tuesday, March 7, 2017 4:46 PM