Validation Checks that the data entered is sensible.

12
Validation Checks that the data entered is sensible

Transcript of Validation Checks that the data entered is sensible.

Page 1: Validation Checks that the data entered is sensible.

Validation

Checks that the data entered is sensible

Page 2: Validation Checks that the data entered is sensible.

Input masks

Page 3: Validation Checks that the data entered is sensible.

• 0 User must enter a digit (0 to 9).

• 9 User can enter a digit (0 to 9).

• # User can enter a digit, space, plus or minus sign. If skipped, Access enters a blank space.

• L User must enter a letter.

• ? User can enter a letter.

• A User must enter a letter or a digit. a User can enter a letter or a digit. • & User must enter either a character or a space.

• C User can enter characters or spaces. • The character you select depends on your Microsoft Windows regional settings.

• > Coverts all characters that follow to uppercase.

• < Converts all characters that follow to lowercase.

• ! Causes the input mask to fill from left to right instead of from right to left.

• \ Characters immediately following will be displayed literally.

• "" Characters enclosed in double quotation marks will be displayed literally.

Page 4: Validation Checks that the data entered is sensible.

Tasks

• LEVEL 1 Create an input Mask for a Postcode• LEVEL 2 Create an input Mask for a car

registration• LEVEL 3 User enters a first or last name with

the first letter automatically capitalised.• LEVEL 4 Or Own INPUT MASK

Page 5: Validation Checks that the data entered is sensible.

EXPRESSION BUILDER

A mathematical expression that checks that the data added is valid and

within a ‘valid’ range

=Now()

Page 6: Validation Checks that the data entered is sensible.

EXPRESSION BUILDER

Page 7: Validation Checks that the data entered is sensible.

Validation

Page 8: Validation Checks that the data entered is sensible.

ValidationOperator Description Example Comment

= Equal to =100 Only a number of 100 is accepted

<> Not equal to <>0 Any number except 0(zero) is accepted

< Less than <250 Numbers less than 250 are accepted. 250 is not accepted

<= Less than or equal to

<=250 Numbers less than 250 are accepted. 250 is also accepted.

> Greater than >1234 Numbers greater than 1234 are accepted. 1234 is not accepted.

>= Greater than or equal to

>=1234 Numbers greater than 1234 are accepted. 1234 is also accepted

Page 9: Validation Checks that the data entered is sensible.

Validation

Validation rule Comment

>#17/10/03# Only dates later than 17 October 2003 are accepted, but not that date itself.

<>#09/02/92# Any date is accepted except 9 February 1992

<=#26/11/95# Only dates earlier than 26 November 1995 are accepted, as is the date itself.

=Date() Only today’s date is accepted.

<Date() Only dates before today’s date are accepted. Today’s date is not allowed.

>=Date() Only today’s date, or any future date, is accepted.

Page 10: Validation Checks that the data entered is sensible.

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 digitsIs 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 -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 NullSame as setting the field's Required property, but lets you create a custom message (in the Validation Text property.)

Limit to specific choicesIs 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 (1, 2, 4, 8) The IN operator may be simpler than several ORs.

Yes/No/Null field Is Null OR 0 or -1The 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.)

Page 11: Validation Checks that the data entered is sensible.

Tasks

• LEVEL 1 Create a validation rule for Male and Female

• LEVEL 2 Create a validation rule for a numerical field (above or below a certain number)

• LEVEL 3 Create your own validation rule

Page 12: Validation Checks that the data entered is sensible.

DATA VALIDATION LISTS