0

I have a dropdown with parameters Student Name and Student Id. When I select Student Name a textbox appears as below and have the submit button:

enter image description here

On clicking Student ID the report parameter is displayed as below:

enter image description here

For both Student name and student Id am using the dataset StudentDetails. When the report runs if the value for student Name is not found should display message “Student Name not found” and if Student Id is incorrect should display message “Student Id not found”.
On the report I have added a textbox to display the message with the expression as below:

enter image description here

=SWITCH(
        First(Fields!StudentName.Value, "StudentDetails")=""," Student Name not found ",
        First(Fields!StudentId.Value, " StudentDetails ")=""," Student Id not found ")

When incorrect student name is input the message appears correctly, however, for incorrect student id still the same message is displayed “Student Name not found”

Thanks for helping

hash.f
  • 1
  • 1

1 Answers1

0

You either need to nest the IIF statements like this

=IIF(
    First(Fields!StudentName.Value, "StudentDetails")="","Student Name not found",
    IIF(
        First(Fields!StudentId.Value, "StudentDetails")="","Student Id not found"
        ,"")) 

or use a SWITCH statement which is usually easier to read.

=SWITCH(
        First(Fields!StudentName.Value, "StudentDetails")="","Student Name not found",
        First(Fields!StudentId.Value, "StudentDetails")="","Student Id not found"
        )

Edit after update from OP

SWITCH will stop at the first expression that is true so if you want to report that both are empty then you will need to add another expression to the SWITCH statement

=SWITCH(
        First(Fields!StudentName.Value, "StudentDetails")="","Student Name not found",
        First(Fields!StudentId.Value, "StudentDetails")="","Student Id not found",
        First(Fields!StudentName.Value, "StudentDetails")="" AND First(Fields!StudentID.Value, "StudentDetails")="","Student Name AND ID not found"
        )

If this does not work then add text boxes to debug each expression, it might be that, for instance StudentID is numeric datatype and therefore you will have to adjust the test to suit (e.g. = Nothing)

Alan Schofield
  • 19,839
  • 3
  • 22
  • 35
  • i try both statement but only the msg "Student Name not found" is displayed. – hash.f May 20 '21 at 11:29
  • for studentname is ok but click on the next parameter for student id still the same msg displays for incorrect studentid – hash.f May 20 '21 at 11:31
  • you mentioned noting about parameters. Please edit your question and provide a full explanation. Include sample data where relevant and what you expect to see and where. Mock up an image if this helps explain what you expect to see. – Alan Schofield May 20 '21 at 15:10
  • thanks, i have edited the question. i want the eror message to display according for incorrect student name and Student Id – hash.f May 20 '21 at 16:18
  • I've updated hte answer but you have not really provided much more info, in your parameters, what does the user see, what are they value and label properties for each etc... – Alan Schofield May 20 '21 at 16:48