Locked lesson.
About this lesson
Add three numeric fields to the table and set the properties for each including data validation rules.
Exercise files
Download this lesson’s related exercise files.
3.04 numeric-fields-data-validation - Exercise.docx43.8 KB 3.04 numeric-fields-data-validation - Exercise solution.docx
88.9 KB TechGurusTicketing05.accdb
548 KB TechGurusTicketing05 - Complete.accdb
564 KB Ticket_Example.txt
309 B
Quick reference
Adding Numeric Fields and Setting Validation Rules
In this lesson, we are going to complete our table by adding the final three numeric fields and setting up validation rules and text to control the values entered into the field.
When to use
Numeric fields are used whenever we want to add a field that contains numbers instead of text. We can apply validation rules and text to any field, numbers, or text to help control the information going into the field and provide users with helpful instruction.
Instructions
Adding Numeric Fields
So far, the fields we have added to the table have all been text fields. Now, it's time to add some numeric fields to show the date the ticket was logged, the charge amount, and the SLA.
- From the Home tab, click Views and select Design View.
- Click in the Field Name column and type 'DateLogged'.
- Press the Tab key.
- In the Data Type column, select Date from the menu.
- In the Description column, type 'Date the ticket was logged'.
The format for the date field should be changed to 'Medium'.
- Click in the Field Name column and type 'Charge'.
- Press the Tab key.
- In the Data Type column, select Currency from the menu.
- In the Description column, type 'Charge to fix this issue'.
- Click in the Field Name column and type 'SLA'.
- Press the Tab key.
- In the Data Type column, select Number from the menu.
- In the Description column, type 'Service Level Agreement for this ticket'.
- Set Field Properties as required.
Adding Validation Rules and Text
Validation allows us to set a rule on our field and pop up a message if something is entered into the field that isn't valid. We can add useful text to the message to let users know what needs to be entered into the field.
For example, there is a minimum call-out charge of $50. So, any value that is entered into the 'Charge' field must be greater than or equal to $50.
- Select the 'Charge' field.
- Click in the Validation Rule field property and type '>=50'.
If a user enters a number below 50, we want a message to pop up that displays validation text.
- Click in the Validation Text field and type 'Minimum charge must be greater than or equal to 50'.
- Click in the Required field and select Yes.
- Click in the Indexed field and select Yes (Duplicates OK).
Testing the Validation Rule
- From the Home tab, click Views and select Datasheet View.
- Click in the Charge column.
- Type a number less than 50.
If the validation rule has been created correctly, a pop-up message should appear that displays the validation text.
Applying Number Formatting
Numeric values can be formatted. For example, we can change the number of decimal places, the currency symbol, and add a comma separator. Formatting options are found on the Table Fields ribbon in the Formatting group.
Hints & tips
- The default currency format we see in the datasheet view is determined by our region settings on our PC.
Lesson notes are only available for subscribers.