April 13, 200817 yr Hi I am using an If function in a script where i wish the outcome based on two possible entries in a field. For example I wish an action to happen if the Status field in the Customer table equals M2 or TBR. I have tried the calculation Customers::Status ≠ "M2" xor "TBR" and a number of other possible variations. Can anyone let me know where I am going wrong.
April 13, 200817 yr Try this: If [ Status = "M2" or Status = "TBR" ] #do something End If Just saw the comment, "and other possible variations." Why don't you explain further. You may need to set a flag field that describes the state of the record, and use that in your If script statement. Edited April 13, 200817 yr by Guest added more
April 13, 200817 yr Author Hi thanks that does work. The problem I am having is when I turn it around to being not equal to. When I change the formula from Customers::Status = "M2" or Customers::Status = "TBR" (Which works) to Customers::Status ≠ "M2" or Customers::Status ≠ "TBR" is does not perform as expected, ie performing the action when the status field is not M2 or TBR. The formula does work however it it is just one result eg. Customers::Status ≠ "M2"
April 13, 200817 yr Author I have made this work by changing the code to the following: (Customers::Status = "M2" or Customers::Status = "TBR") = False
April 13, 200817 yr That is not a valid calculation. Two not equals doesn't work because it may always be true. What is the complete test?
April 13, 200817 yr I not sure what you are trying to do, but have you tried the Else If statment? If ( Customers::Status = "M2" ) Do something Else If (Customers::Status = "TBR") Do something Else If (Customers::Status = "X") Do something else
April 13, 200817 yr (Customers::Status = "M2" or Customers::Status = "TBR") = False That is not a valid calculation. Of course it is. It's not only valid, but also correct. It's the same as: not ( Customers::Status = "M2" or Customers::Status = "TBR" ) which could also be written as: Customers::Status ≠ "M2" [color:red]and Customers::Status ≠ "TBR"
April 13, 200817 yr (Customers::Status = "M2" or Customers::Status = "TBR") = False But isn't that asking: ( 1 ) = False or ( 0 ) = False It would always fail. IIRC, false hasn't been boolean 0 since vs. 6; along with F & N & no. False is no longer not, no? Edited April 13, 200817 yr by Guest
April 13, 200817 yr Let's not get confused here. Text values like "Y", "N", "T", "F", "True" and "False" are no longer evaluated as Boolean. But the reserved keywords True and False can be used in a calculation formula instead of 1 and 0.
April 13, 200817 yr Oh, right! Not sure why I saw "False" when Barbara said it wasn't valid; maybe she saw it same way I did. Without quotes, it is certainly valid! Thanks for the reminder, Michael.
April 14, 200817 yr Customers::Status ≠ "M2" and Customers::Status ≠ "TBR" That is a construct I do use, although I prefer to write in positive case when possible. I'm not familiar with the use of False, my apologies, it just looked so wrong. It certainly doesn't read as well to me. Anywho, I think that Lee's suggestion is probably the way to go if the tests are numerous. But since we don't have enough info, it's just guessing at this point.
Create an account or sign in to comment