On page 247, the authors (or more likely, the single author of the chapter--I can't imagine that
all of them would get this wrong), make a serious error in describing VBA's handling of If tests. They state:
"In fact, in Access VBA any value other than -1 is false, so the value 2 is always false."
This is precisely the opposite of the case. It's correct that testing the value of True will yield -1, but it is
much more significant that the value of False is 0.
Anything that evaluates to non-zero is treaed as "not False", and therefore True. Try this:
Code:
Sub bar()
If 2 Then
Debug.Print "Not False"
Else
Debug.Print "Not True"
End If
End Sub
The result that's printed is "Not False".
So the problem with the "horrible example" code is that the "interesting code" will
always run, regardless of the value of intOrderStatus, not that it won't run when intOrderStatus is 2.
I'm glad I didn't see this in the bookstore, or I might have left the book behind as "not trustworthy". It's been a big help in other ways.... As an aside that might help one to remember that "not False" takes precedence over "not True", the reason for the value of True is that the literal, bitwise "Not" of the value Integer 0 is the Integer value -1 (stored, as all negative values, as a 2's complement).