Search code examples
reporting-servicesreportingssrs-2012

how to create a textbox in ssrs for user entry as a parameter and limit the Character input to 18


I have a blank text paramter that I need for the user to write a small response to fill in a blank on the report. However, I don't want the user to be able to write a book in the textbox.

Any help would be greatly appreciated

I have the box working. I set the parameter properties to "Allow Blank Value". And referencing the Parameter in the table. Whatever is written in the text box shows on the report. I just need to limit the text.


Solution

  • This is not a solution as such but too long for a comment.

    Assuming you don't want the report to even start running unless the response <=18 characters then ...

    There is not built in way to validate parameter lengths as far as I know. You could add a hidden parameter and set the default property to

    =LEN(Parameters!response.Value)
    

    Then add number 0 thru 18 to the available values list.

    This will work but only the first time you enter some text and then click/tab away from the response field. If you entered "test" and tabbed away the hidden parameter would be set to 4, all good, if you then edit "test" and change it to "this is far too long to fit" then the hidden parameter value won't change.

    The only other approach, without writing something yourself to run & display the report, would be to do this in the dataset query so it returns and empty dataset.

    Something simple like

    SELECT * FROM myTable WHERE LEN(@Response) <= 18 
    

    When @Response is too long, no records will be returned so you can, assuming a table is present in your report, set the table's NoRowsMessage to something like "Response exceeds 18 characters" for whatever.