That's just luck I'm afraid - you aren't checking the error code at all (what you are accidentally doing there is actually a Bit manipulation and conversion to boolean, which will always be true).

It should be like this:
Code:
If Err.Number = adRecIntegrityViolation Or Err.Number = adErrIntegrityViolation Then