Error message when executing expression in text box

  • I'm trying to execute the following but I get an error (#Error) after the report has rendered and therefore the required text below does not display in the text box, although the rest of the report displays fine:

    =iif(Parameters!P_Period.Value=1,"1st April to 30th April",Nothing)

    =iif(Parameters!P_Period.Value=2,"1st May to 31st May ",Nothing)

    =iif(Parameters!P_Period.Value=3,"1st June to 30th June ",Nothing)

    =iif(Parameters!P_Period.Value=4,"1st July to 31st July ",Nothing)

    =iif(Parameters!P_Period.Value=5,"1st August to 31st August",Nothing)

    =iif(Parameters!P_Period.Value=6,"1st September to 30th September",Nothing)

    =iif(Parameters!P_Period.Value=7,"1st October to 31st October",Nothing)

    =iif(Parameters!P_Period.Value=8,"1st November to 30th November",Nothing)

    =iif(Parameters!P_Period.Value=9,"1st December to 31st December",Nothing)

    =iif(Parameters!P_Period.Value=10,"1st January to 31st January",Nothing)

    =iif(Parameters!P_Period.Value=11,"1st February to 28th February",Nothing)

    =iif(Parameters!P_Period.Value=12,"1st March to 31st March",Nothing)

    The error states: [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox5.Paragraphs[0].TextRuns[0]’ contains an error: Operator '=' is not defined for type 'Object()' and type 'Integer'.

    I have also replaced the above expression with:

    =Switch(Parameters!P_Period.Value=12, "1st March to 31st March " ,

    Parameters!P_Period.Value=1, "1st April to 30th April ",

    Parameters!P_Period.Value=2, "1st May to 31st May ",

    Parameters!P_Period.Value=3, "1st June to 30th June ",

    Parameters!P_Period.Value=4, "1st July to 31st July ",

    Parameters!P_Period.Value=5, "1st August to 31st August ",

    Parameters!P_Period.Value=6, "1st September to 30th September ",

    Parameters!P_Period.Value=7, "1st October to 31st October ",

    Parameters!P_Period.Value=7, "1st October to 31st October ",

    Parameters!P_Period.Value=8, "1st November to 30th November ",

    Parameters!P_Period.Value=9, "1st December to 31st December ",

    Parameters!P_Period.Value=10, "1st January to 31st January ",

    Parameters!P_Period.Value=11, "1st February to 28th February "

    )

    ...but I then get this error:

    [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox5.Paragraphs[0].TextRuns[0]’ contains an error: Overload resolution failed because no Public '=' can be called with these arguments:

    'Public Shared Operator =(a As String, b As String) As Boolean':

    Argument matching parameter 'a' cannot convert from 'Object()' to 'String'.

    I've swapped the P_Period parameter to int and text, but I still get an error.

    I'm a bit of newbie with this, so any help would be appreciated.

    Cheers

  • Try putting your values in quotes.

    What you have

    Parameters!P_Period.Value=12

    What I am suggestiong

    Parameters!P_Period.Value="12"

    Also, is Parameters!P_Period a multi value parameter?

  • Thanks for the reply - I've tried putting the values in quotes, but it doesn't seem to make a difference.

    Re "is Parameters!P_Period a multi value parameter?" - the answer is yes.

    Cheers

  • Canazei65 (12/14/2011)


    Thanks for the reply - I've tried putting the values in quotes, but it doesn't seem to make a difference.

    Re "is Parameters!P_Period a multi value parameter?" - the answer is yes.

    Cheers

    Since this is a multivalue parameter you need to use Parameters.parametername.Value(0) to get the selected value. If there is more than one value selected this will show the first one in the list.

  • Thanks - I'll try this in the morning.

    Cheers

  • Thanks again - I've tried this and it does work.

    However, I don't just want the choice of the 1st value in the list i.e. If I choose 2 I want "1st May to 31st May " to be displayed in the text box, but if I use the Value(0) method it will still display "1st Aprril to 30th April".

    Any further suggestions welcomed.

    Cheers

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply