Originally posted by stein if (lngI=12 AND lngJ<>6 ) or bolTest then
Does not do what I think you wanted to do.
This, is what the code does....
if (lngI=(12 AND lngJ)<>6 ) or bolTest then
(see the "hidden" bit-wise AND operation?)
Change your code to this...
if ((lngI=12) AND (lngJ<>6)) or bolTest then
Thanks for your help. I guess I didn't do a good job of explaining exactly what I'm trying to do. I have fields called "LastReport", "NCOsDEROS," "RatersDEROS" and "NextReportDue" in addition to the two fields listed in my expression below. I have the "DATEDIF" expression in those two fields. I want the "LastReport" field to be the trigger that enters either "COR" or "NA" in the field "NextReportDue." The criteria for "COR" is both fields must be 90-days or more, less than 90-days by either field will result in "NA." Here is my expression that I'm trying to use:
=IIf([DaysSinceLastReport&NCOsDEROS]>90 And [DaysSinceLastReport&RatersDEROS]>90,"COR","NA").
The problem is whenever I change the date in "LastReport", the result in "NextReportDue" does not change. It either stays at "COR" or "NA."
I'm slightly bemused by your syntax - have the characters become garbled in your post or have I totally misunderstood the situation (always a strong possibility). The basic Iif syntax is correct but what are these brackets doing in the conditional part? As far as I know Access will interpret everything inside brackets as a name - field, control, form, whatever. Yet you have included an ampersand in that character string which makes me suspect that there is some intent at nested logic or arithmetic. I've just looked up again to see if there is some use of '&' of which I am unaware but Access help has no other use apart from the string concatenation function.
Are you trying to add two values such as Iif(((value1 + value2) > 90) AND ((value3 + value4) > 90), true,false) I cannot agree more with the previous poster who implied that the more parentheses you use the less chance there is of falling foul of syntax defaults.
Final point in my rambles: where are you using this expression? Be careful if you are using it in the On Format, On Print, On Current type events. Make sure that the values in the condition are what you expect. For example I often store a value from the previous row and use it to check contiguity in the succeeding row on a report. this works fine as long as you move forward through the report but fails on the first line of every page if you page backwards through the report.