Search code examples
validationms-accessms-access-2016

Microsoft 365: Access 2016: Validation rule: Number Data Type: No decimals


I'd like to know what validation rule I would want to write if I want to prevent the inclusion of decimals in my number field.

If possible, I'd like to do this only in the validation rule line in Design View, and not have to touch VBA.

I've tried other exclusion validation rules but they don't work with Access 2016


Solution

  • You can substract the integer portion to get only the decimals, and test if that's 0, in a field-level validation rule e.g.:

    MyField - Int(MyField) = 0
    

    However, you could also just store your values as a Long Integer, making it impossible to store decimal values because they just don't fit in there.