IF statement not working

Hi guys,

I have a WebQuerySave agent that has a basic If… Then… statement structure.

On the form i have a field that is populated with a value on submission of the form, field is called SaveRef.

Agent:

// Declarations ////////

Msgbox SaveRef

If SaveRef = “Submit” Then

Call A

End If

If SaveRef = “Reject” Then

Call B

End If

If SaveRef = “Manager” Then

Call C

End If

Else

Call D

End If

What happens is that the code is only excuting the the last Else. For example, i have checked on the server and the Msgbox at the start may say Manager yet will not call C. It only calls D.

Any ideas? Something to do with the structure of the If Then??

Subject: IF statement not working

Change your Ifs to Elsif’s.

Subject: RE: IF statement not working

Agent:

// Declarations ////////

Msgbox SaveRef

If SaveRef = “Submit” Then

Call A

End If

Else If SaveRef = “Reject” Then

Call B

End If

Else If SaveRef = “Manager” Then

Call C

End If

Else

Call D

End If

??

Subject: IF statement not working

What Lisa said is correct but you could also do this:

Select Case SaveRef

Case “Submit”

Call A

Case “Reject”

Call B

Case “Manager”

Call C

Case Else

CALL D

End Select

Subject: RE: IF statement not working

Oh yes, i forgot about the Case statement… This should work fine. Thanks!

Subject: IF statement not working

The reason that it does not work is because the MsgBox function returns an integer, not a string. None of the conditions that you are testing for would ever be true, so your catchall statement always fires.

Subject: IF statement not working

This is obviously not your complete code. All your Ifs are closed by corresponding End Ifs, so you have an Else that doesn’t match a preceding If. And you don’t show how you set the value of SaveRef. Note: LotusScript programming is not like Formula programming. Just giving a variable a name that matches a field on a form does not automatically give that variable the value of that field.