Validation rules for certain fields, Cheat Sheet of Computer Science

Validation rules for certain fields in a databse, when creating a database

Typology: Cheat Sheet

2022/2023

Uploaded on 06/27/2023

anas-asif-1
anas-asif-1 🇦🇪

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Validation Rules for fields
When you select a field in table design, you see itsValidation Ruleproperty in thelower
pane.
This rule is applied when you enter data into the field. You cannot tab to the next field until
you enter something that satisfies the rule, or undo your entry.
To do
this ...
Validation
Rule for
Fields
Explanation
Accept
letters (a - z)
only
Is Null OR Not
Like "*[!a-z]*"
Any character outside the range A to Z is rejected. (Case
insensitive.)
Accept digits
(0 - 9) only
Is Null OR Not
Like "*[!0-9]*"
Any character outside the range 0 to 9 is rejected. (Decimal
point and negative sign rejected.)
Letters and
spaces only
Is Null Or Not
Like "*[!a-z OR
"" ""]*"
Punctuation and digits rejected.
Digits and
letters only
Is Null OR Not
Like "*[!((a-z)
or (0-9))]*"
Accepts A to Z and 0 to 9, but no punctuation or other
characters.
Exactly 8
characters
Is Null OR Like
"????????" The question mark stands for one character.
Exactly 4
digits
Is Null OR
Between 1000
And 9999
For Number fields.
Is Null OR Like
"####" For Text fields.
Positive
numbers only
Is Null OR >=
0Remove the "=" if zero is not allowed either.
No more
than 100%
Is Null OR
Between -1
And 1
100% is 1. Use 0 instead of -1 if negative percentages are
not allowed.
Not a future
date
Is Null OR <=
Date()
Email
address
Is Null OR
((Like "*?@?*.?
*") AND
 (Not Like
"*[ ,;]*"))
Requires at least one character, @, at least one character,
dot, at least one character. Space, comma, and semicolon
are not permitted.
You must fill
inField1 Not Null Same as setting the field'sRequiredproperty, but lets you
create a custom message (in theValidation Textproperty.)
Limit to
specific
choices
Is Null OR "M"
Or "F"
It is better to use a lookup table for the list, but this may be
useful for simple choices such as Male/Female.
Is Null OR IN The IN operator may be simpler than several ORs.
pf2

Partial preview of the text

Download Validation rules for certain fields and more Cheat Sheet Computer Science in PDF only on Docsity!

Validation Rules for fields

When you select a field in table design, you see its Validation Rule property in the lower pane. This rule is applied when you enter data into the field. You cannot tab to the next field until you enter something that satisfies the rule, or undo your entry. To do this ... Validation Rule for Fields Explanation Accept letters (a - z) only Is Null OR Not Like "[!a-z]" Any character outside the range A to Z is rejected. (Case insensitive.) Accept digits (0 - 9) only Is Null OR Not Like "[!0-9]" Any character outside the range 0 to 9 is rejected. (Decimal point and negative sign rejected.) Letters and spaces only Is Null Or Not Like "[!a-z OR "" ""]" Punctuation and digits rejected. Digits and letters only Is Null OR Not Like "[!((a-z) or (0-9))]" Accepts A to Z and 0 to 9, but no punctuation or other characters. Exactly 8 characters Is Null OR Like "????????" The question mark stands for one character. Exactly 4 digits Is Null OR Between 1000 And 9999 For Number fields. Is Null OR Like "####" For Text fields. Positive numbers only Is Null OR >= 0 Remove the "=" if zero is not allowed either. No more than 100% Is Null OR Between - And 1 100% is 1. Use 0 instead of -1 if negative percentages are not allowed. Not a future date Is Null OR <= Date() Email address Is Null OR ((Like "?@?.? ") AND (Not Like "[ ,;]*")) Requires at least one character, @, at least one character, dot, at least one character. Space, comma, and semicolon are not permitted. You must fill in Field1 Not Null^ Same as setting the field's Required property, but lets you create a custom message (in the Validation Text property.) Limit to specific choices Is Null OR "M" Or "F" It is better to use a lookup table for the list, but this may be useful for simple choices such as Male/Female. Is Null OR IN The IN operator may be simpler than several ORs.

Yes/No/Null field Is Null OR 0 or

  • The Yes/No field in Access does not support Null as other databases do. To simulate a real Yes/No/Null data type, use a Number field (size Integer) with this rule. (Access uses 0 for False, and -1 for True.)