Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION TO DATABASE USING MICROSOFT ACCESS 2013 Part 5.2 November 16, 2014.

Similar presentations


Presentation on theme: "INTRODUCTION TO DATABASE USING MICROSOFT ACCESS 2013 Part 5.2 November 16, 2014."— Presentation transcript:

1 INTRODUCTION TO DATABASE USING MICROSOFT ACCESS 2013 Part 5.2 November 16, 2014

2 TYPES OF VALIDATION RULE

3 FIELD VALIDATION RULE Use a field validation rule to check the value that you enter in a field when you leave the field. For example, suppose you have a Date field, and you enter >=#01/01/2007# in the Validation Rule property of that field. Your rule now requires users to enter dates on or after January 1, 2007. If you enter a date earlier than 2007 and then try to place the focus on another field, Access prevents you from leaving the current field until you fix the problem.

4 RECORD VALIDATION RULE Use a record validation rule to control when you can save a record (a row in a table). Unlike field validation rules, record validation rules refer to other fields in the same table. You create record validation rules when you need to check the values in one field against the values in another. For example, suppose your business requires you to ship products within 30 days and, if you don't ship within that time, you must refund part of the purchase price to your customer. You can define a record validation rule such as [RequiredDate]<=[OrderDate]+30 to ensure that someone doesn't enter a ship date (the value in the RequiredDate field) too far into the future.

5 WHERE YOU CAN USE VALIDATION RULES You can define validation rules for tables and for controls on forms. When you define rules for tables, those rules apply when you import data. To add validation rules to a table, you open the table in Design view and set various table properties. To add validation rules to a form, you open the form in Design view and add rules to the properties of individual controls.

6 WHAT YOU CAN PUT IN A VALIDATION RULE Your validation rules can contain expressions — functions that return a single value. You can use expressions to perform calculations, manipulate characters, or test data. When you create validation rules, you use expressions primarily to test data. For example, an expression can check for one of a series of values, such as "Tokyo" Or "Moscow" Or "Paris" Or "Helsinki". Expressions can also perform mathematical operations. For example, the expression <100 forces users to enter values less than 100. The expression ([OrderDate] - [ShipDate]) calculates the number of days that elapsed between the time an order was placed and the time it shipped.

7 CREATING A VALIDATION RULE

8 BEGIN Click MS Access 2013 On the MS Access Screen Pane, select Blank Database Create a name that will reserve as your file for the database

9 In the screen pane, click blank desktop database

10 In the screen box, click the browse button to save in any file that you want Write your name in the box that you want to save your database Click create if done

11 IN THE MS ACCESS ENVIRONMENT Right Click the “Table 1”.

12 Click Design View

13 Save first. Write your name inside the Table Name Box Click “OK” if done.

14 You are now in the Design View.

15 HOW TO ADD FIELDS IN THE DESIGN VIEW Write first your Field Name.

16 Second, select from the data type that you want.

17 Third, is to write a short description based on your field name.

18 If you're done. Click the General Properties (Field) to emphasize your field.

19 CREATING A VALIDATION RULE In the validation rule, follow the format that was given in Part 5.1

20 For example You can get input mask as much as possible if you want.

21 CREATING A VALIDATION RULE IN A DIFFERENT WAY Click the button with …

22 The button has been entered and you can write some functions. After you write expressions in the Expression Builder, click OK.

23 After your done, creating the validation rule. You need to write first your validation text before you save. Like this.

24 PUTTING IT IN THE DATABASE VIEW Right Click Table1. Click Datasheet View. Don’t forget to save your design view

25 YOU ARE NOW IN THE DATASHEET VIEW

26 You can get more records when you are in the datasheet view. A sample will be like this.

27 WHAT IF THE REQUIRED FIELD CAN’T BE

28 The message is So you need to be sensitive in writing your field. Check your Design View if it follows the format for the validation rule.

29 Then it backs

30 If you want to change your Validation Rule. As long as it follows the format in there.

31 VALIDATE DATA DURING ENTRY IN FORMS The easiest and fastest way to apply a validation rule to a form is to first add the rule to the underlying table field, and then use the automated form-creation tools that Access provides to create a form. For example, on the Create tab, in the Forms group, you can choose to have Access create a simple form, a split form, a multiple- item form, and more. When you use one of those tools, the controls on the form inherit the underlying table properties, including any validation rules and validation text. You can also apply a validation rule to a form control by opening the form in Design view and adding a rule to the Validation Rule property and message text to the Validation Text property of the control. You can add validation rules to some, but not all, form controls. The easiest way to determine if you can add a validation rule to a control is to open the form in Design view and follow the steps in this section.

32 Remember that a control can have a different validation rule than the table field to which the control is bound. When a conflict develops between validation rules, the rule defined for the table field takes precedence. Also, remember that rules in controls and table fields can cancel each other out and thus prevent you from entering any data at all. For example, suppose you apply the following rule to a date field in a table: <#01/01/2007# But you then apply this rule to the form control bound to the table field: >=#01/01/2007# The table field now requires values earlier than the year 2007, but the form control forces you to enter dates after that year, thus preventing you from entering any data at all. If you try to enter data under those conditions, Access tells you to enter dates before and after those specified by the conflicting validation rules, and you find yourself caught in an endless loop. The following steps explain how to add validation rules to controls, and how to lock controls and thus prevent users from altering data.


Download ppt "INTRODUCTION TO DATABASE USING MICROSOFT ACCESS 2013 Part 5.2 November 16, 2014."

Similar presentations


Ads by Google