Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this code correct??

Status
Not open for further replies.

nike2000

Technical User
Apr 1, 2003
61
GB
Hi there,
Can you let me know if the following code is correct?
The logic is; if any of these fields are a 'Yes', 'Yes' should be returned. All should be 'No' but if any are 'Yes' it should be highlighted.
Have I written it correctly?
Thanks

=IIf([DatesChange]="Yes" Or [CreditEventsChange]="Yes" Or [RefEntityNameChange]="Yes" Or [RefObNameChange]="Yes" Or [ObCharacteristicsChange]="Yes" Or [ObCategoriesChange]="Yes" Or [DelObCategoriesChange]="Yes" Or [DelObCharacteristicsChange]="Yes","Yes","No")
 
Looks OK to me; you presumably have a problem with it?

Brian
 
yes.
its not returning the correct information back.
i've tried placing it in a query and receive a data type mismatch error.
and i have also placed it in a form that is derived from the query and still have the same problem.
any suggestions?
Nike
 
I think perhaps you are using Yes/No fields, and yet you are trying to compare them with the string value "Yes", hence the "data type mismatch error".

Try replacing all the '= "Yes"' in your statement with '= TRUE' (but leave the final "Yes" and "No" in place, as they are your "output" values).

Regards,

Brian
 
hey Brian,
I have even changed the formats of the fields on the tables to True/False and am still receiving the same error.
I have even written a query with just the above if statement with the same results.
can't think what the problem could be.
Nike
 
It worked by using True instead of "True".
Thanks for your help.
Nike
 
I usually use nested IIf statement in these type of situtations and have not had a problem. Like this

=IIf([DatesChange]="No", IIf([CreditEventsChange]="No", IIf([RefEntityNameChange]="No", IIf( [RefObNameChange]="No", IIf([ObCharacteristicsChange]="No", IIf([ObCategoriesChange]="No", IIf([DelObCategoriesChange]="No", IIf([DelObCharacteristicsChange]="No","No","Yes"))))))))

Also do you set a default value for each of these fields so your not trying to check a null field?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top