Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am having trouble with using an IF statement to check if values have been selected in fields and then setting a variable accordingly.
What I have is a button with a number of select actions. I will select a value in one field, then lock that field so that the next selection does not override the previous, then at the end I want to check if all of my selections were successful and say success or failure depending on the result. For example:
Select 'Australia' in Country
Lock Country
Select 'Unrated' in Rating
Lock Rating
Select (16-20|21-30) in Age_Group
Lock Age_Group
SetVariable varCheck: IF (Country = 'Australia' AND Rating = 'Unrated' AND (Age_Group = '16-20' OR Age_Group = '21-30'), 'Success', 'Failure')
The two possibilities should be: (1) all of the fields have been selected with the values set, or (2) some of them have been selected and other fields are unselected due to those values not being available after the previous fields were selected.
So at first what was happening is that my IF statement was resulting in both 'Success' and 'Failure' even though I had selected and locked these fields and they all have available values which I checked with a listbox expression. I still don't understand this. So I change the IF statement as such:
IF (Country = 'Australia', IF (Rating = 'Unrated' , IF(Age_Group = '16-20' OR Age_Group = '21-30', 'Success', 'Failure')))
Now I get one available possibility being 'Success' when the selections have been done. But when the variable is set it is not always set to 'Success'. I will click the button for the first time and the variable will display null, then when I click it again (without clicking other buttons) I get 'Success'.
Can anyone please enlighten me as to what is going on here? Why I sometimes get null and sometimes get 'Success' in the variable even though all of the criteria is fulfilled? Thanks.
Barry
Also, all continuing clicks of the button will result in 'Success', only the first click gives null.
Ok, I found that if I put the expression into the actual variable contents then it sometimes works. It works if for example, the only age group available is '16-20', but if both ages groups are available I get 'Failure'. When the expression is put in a list box it say 'Success'.