3 Data Properties and Validation Rules



Similar documents
Field Name Data Type Description Field Size Format

Utility Software II lab 1 Jacek Wiślicki, jacenty@kis.p.lodz.pl original material by Hubert Kołodziejski

MS Access: Advanced Tables and Queries. Lesson Notes Author: Pamela Schmidt

.NET Standard DateTime Format Strings

Access 2010 Intermediate Skills

Field Properties Quick Reference

Microsoft Access 2010 Tables & Field Properties

How to set up a database in Microsoft Access

Lab Manual. Databases. Microsoft Access. Peeking into Computer Science Access Lab manual

MS Access Lab 2. Topic: Tables

The column containing phone numbers is a field

Access Part 2 - Design

MS ACCESS DATABASE DATA TYPES

Table and field properties Tables and fields also have properties that you can set to control their characteristics or behavior.

How To Create A Database For Employee Records In A Club Account In A Computer System In A Cell Phone Or Cell Phone With A Cell Computer (For A Cell)

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

European Computer Driving Licence

Databases with Microsoft Access. Using Access to create Databases Jan-Feb 2003

What is a database? The parts of an Access database

If the database that is required is similar to a template then whole database can be generated by using a template that already exists.

C omputer D riving L icence

Creating a Database in Access

Chapter 5. Microsoft Access

How To Understand The Basic Concepts Of A Database And Data Science

Using Microsoft Access

Access Creating Databases - Fundamentals

Microsoft Dynamics GP. SmartList Builder User s Guide With Excel Report Builder

Introduction to Microsoft Office Access 2010

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Introduction to Python

MICROSOFT OFFICE ACCESS LEVEL 2

Setting up a basic database in Access 2007

ECDL. European Computer Driving Licence. Database Software BCS ITQ Level 1. Syllabus Version 1.0

Working with Access Tables A Continuation

Introduction to Microsoft Access 2010

IN THIS PROJECT, YOU LEARN HOW TO

Introduction to Microsoft Access 2013

Database Database Management System (DBMS)

Access I Tables, Queries, Forms, Reports. Lourdes Day, Technology Specialist, FDLRS Sunrise

Retrieving Data Using the SQL SELECT Statement. Copyright 2006, Oracle. All rights reserved.

Import Filter Editor User s Guide

Microsoft Access 2010 Overview of Basics

Commonly Used Excel Formulas

How to Design a Form Report (RTF) Output

MICROSOFT ACCESS A. CREATING A DATABASE B. CREATING TABLES IN A DATABASE

Portal Connector Fields and Widgets Technical Documentation

Template Guide. HTML . Release 8. This template guide is an overview of how to use and customize an HTML templates with Conga Composer.

PL / SQL Basics. Chapter 3

Access NAMES Computerized Database

Creating a Database using Access 2007

Microsoft Access 2007 Module 1

Illinois Veteran Grant (IVG) Online Payment Manual Chapter 4

- Suresh Khanal. Microsoft Excel Short Questions and Answers 1

Chapter 2 Introduction to SPSS

4. The Third Stage In Designing A Database Is When We Analyze Our Tables More Closely And Create A Between Tables

Microsoft Access 3: Understanding and Creating Queries

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Computer Science 125. Microsoft Access Project

Microsoft. Access HOW TO GET STARTED WITH

Using Microsoft Access Databases

10+ tips for upsizing an Access database to SQL Server

Microsoft Access 2003 Module 1

Introduction to Microsoft Jet SQL

In-Depth Guide Database Basics Creating and Populating

Export of audit trail events from Salto software. Version 2.0

User Services. Microsoft Access 2003 II. Use the new Microsoft

Create a New Database in Access 2010

Employment intermediaries: data requirements for software developers

Using AD fields in Policy Patrol

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Microsoft Access Basics

Writer Guide. Chapter 15 Using Forms in Writer

A More Advanced Database Illustration Access 2010

Databases and Microsoft Access II

What You re Missing About Missing Values

Introduction to Microsoft Access

Chapter 15 Using Forms in Writer

INTRODUCTION TO MICROSOFT ACCESS Tables, Queries, Forms & Reports

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Microsoft Using an Existing Database Amarillo College Revision Date: July 30, 2008

Creating an Address Book Database

Microsoft Dynamics GP. Extender User s Guide

Invoice, Statement, and Deposit Slip Layout Variables

LexisNexis PowerInvoice User Guide

Microsoft Access 2010 Part 1: Introduction to Access

X1 Professional Client

Specifications of Paradox for Windows

ACCESS Importing and Exporting Data Files. Information Technology. MS Access 2007 Users Guide. IT Training & Development (818)

Transaction Inquiries

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

Ohio University Computer Services Center August, 2002 Crystal Reports Introduction Quick Reference Guide

WEB USER GUIDE VAULT MEDIA STORAGE

Content. Report Manager Define Search Layout Page Preview Report Report Setup Frequently Asked Questions...

NATIONAL INSTITUTE OF HOTEL MANAGEMENT, KOLKATA

How to Fix Mail-Merge Number Formatting in Word 2010

DEBT COLLECTION SYSTEM ACCOUNT SUBMISSION FILE

How To Use Excel On A Computer Or A Computer With A Cell Phone Or Cell Phone

Participant Guide RP301: Ad Hoc Business Intelligence Reporting

Transcription:

3 Data Properties and Validation Rules 3.1 INTRODUCTION Once a database table has been created and the fields named and the type of data which is to be stored in the field chosen, you can make further refinements to fields by setting field properties. They can be refined to ensure that correct data is entered and that the data is within the required scope of the database. By the end of this section you will be able to: Define field properties Create data validation rules Select custom display formats 3.2 DEFINING FIELD PROPERTIES The field properties are displayed in the lower left hand section of the window (the field properties table) when you go into the design of your table. Here you can specify the data type in more detail, for example, if the data is text you can define the length of a field. The field properties table is shown below Figure (a) The field properties table is different for each different data type. The one shown above is for a number field type. However different data types will contain different data properties. 3.2.1 The data properties Property Description Field Size Maximum length of the text field or type of number Format How the data is displayed Decimal Places Number of places to the right of the decimal Input Mask Data entry pattern Caption Default label used in a form or report Default Value Value entered in afield when records are created Validation Rule Expression that defines data entry rule Page 10

Validation Text Required Allow Zero Length Indexed Text displayed for invalid data entry Determines whether or not an entry must be placed in this field Allows the storage of a zero length string ( ) to indicated data exists but is unknown Single Field indexes to speed searches Field Data Properties 3.3 FIELD SIZE 3.3.1 For text fields: This property sets the maximum size of the data that can be stored in a text field. The longest a text field can be is 255, the shortest 1. You should select the length based on the longest value of data that will be entered into this field. 3.3.2 For numeric fields: You can select from byte, integer, long integer, single and double (default) for numeric fields. Byte: whole numbers between 0 and 255 (occupies 1 byte) Integer: whole numbers between 32,768 and 32,767 (2 bytes) Long integer: whole numbers between 2,147,483,648 and 2,147,483,647 (4 bytes) Single: Decimal numbers with six digits of precision (4 bytes) Double: decimal number with ten digits of precision (8 bytes) 3.4 DEFAULTS Access will assign default values to the fields in your tables. In other words it will automatically put data into a field for you when a new record is created. These values will be dependent on the data type of the field. The default value for Number, currency and yes/no fields is zero, in the case of yes/no fields zero means no, text, memo and date fields are empty by default. You can save time by specifying your own default values for fields. You can specify the default value by either typing in the required value or using an expression. For example, if all your customers come from Bournemouth you might set the default for the Town field to Bournemouth. Or if most customers only order one of a product you might set the quantity field default to 1. You can also use an expression, for example, =Date() which will put the current date into a date field. 3.5 VALIDATION Data entered into a table must be accurate if the database is to be useful. Access can stop users from entering incorrect data by using Validation Rules. If the data input does not match the validation rule then an error message will be displayed, and the data will have to be corrected before it can be saved So for example in a Title field you can make sure the user enters only: Mr, Mrs, Miss or Ms. In a credit limit field you can make sure the value is in a specified range. Some examples: Page 11

If the credit limit must be below 1000 pounds the validation rule would be: <=1000 If the credit limit had to be between 100 and 1000 pounds your validation rule would be: >=100 and <= 1000 For text fields you would type the list of values allowed separated by a semicolon. For example for the title to be Mr, Mrs, Miss or Ms your validation rule would be: Mr or Mrs or Miss or Ms Note: the are needed for this rule because the values are text numerical validation rules do not need them. 3.5.1 Validation Text Along side the validation rule, you can enter the validation text, i.e. the error message that you want to display to the user when they type in an incorrect data item. 3.5.2 Examples of validation rules and text messages Validation Rule setting Validation Text setting <>0 Please enter a nonzero value. 0 Or >100 Value must be either 0 or over 100. Like "K???" Value must be four characters beginning with the letter K. <#1/1/96# Enter a date before 1996. >=#1/1/97# And <#1/1/98# Date must be in 1997. (Taken from the Access help files) 3.6 REQUIRED ENTRY If you set the required property of a field to Yes you will need to enter data for that field in every record. So for example you cannot enter a new customer without the address field being filled in, or you cannot raise a new order without the date being filled in. 3.7 FORMATS Custom formats will display the data in the format that is specified, regardless of the format in which it is entered. Formats vary, depending on the data type used. Some data types have predefined formats, others have only user defined formats, and some have both. So for example you can format a telephone number to look like (01202) 222-4444 or change all the characters to upper or lower case in a text field. 3.7.1 Text and memo formats > Changes all text to uppercase < Changes all text to lower case @ Required text character (character or space) & Text character not required Page 12

The symbols @ and & work with individual characters you input, but the < and > characters affect the whole entry. If you want to make sure the name, for example, is in upper case you enter > in the Format property. If you want to enter a phone number and allow only numbers to be entered, yet display the data with parentheses and a dash, you can enter the following format: (@@@)@@@-@@@@. You can then enter 1227584789 and have the data displayed as (122)758-4789. 3.7.2 Number and Currency formats You can choose from six predefined formats for numeric or currency formats, and symbols for creating your own custom formats. The predefined formats are shown in the tables below, along with a column showing how to define custom formats. Format Number entered Number Displayed Format defined General 987654.321 987654.321 ######.### Currency 987654.321 $987,654.32 $###,##0.00 Fixed 987654.321 987654.321 ######.### Standard 987654.321 987,654.321 ###,###.### Percent.987 98.7% ###.##% Scientific 987654.321 9.87654321E+05 #.####E+00 3.7.3 Date/Time formats The date/time formats are the most extensive, giving you seven predefined options, all of which are fairly self explanatory. You can also use a multitude of user defined date and time settings, some examples are listed below: Date dddd d mmmmm yyyy Tuesday 26 March 1996 ddd d mmm yyyy Fri 10 Dec 1999 dd-mm-yy 10-12-99 d-m-yy 2-5-94 (does not display leading zeros) Time h:mm AM/PM 6:34 PM hh:mm:ss 11:09:57 3.7.4 Yes/No formats The Yes data is stored as a 1, and the No data is stored as a 0, and without a format setting the data will be displayed this way. With formats you can display the Yes/No data in a recognizable manner. The three predefined formats are: Yes/No True/false On/Off (default) displays -1 as Yes and 0 as No -1 is True and 0 is False -1 as On and 0 as Off You can also enter user-defined formats. User defined formats have to start with a semicolon(;), the next section is what text you want to use for Yes (-1) and the third section would be the text required for No (0). So for example, if you had a field for Do you smoke? the answer would be yes or no, but you could display the text smoker or non-smoker. The format for this would be: Page 13

;"Smoker";"Non-smoker" You can even specify a colour to display the different values in, for example: ;"smoker"[red];"non-smoker"[green] 3.8 INPUT MASKS Input masks allow you to have more control over the data entry by defining data validation place holders for each character you enter. For example, if you set the property to (999)000-0000, the parentheses appear as shown, and an underscore (_) appears in place of the 9 or 0 When you have defined an input mask and set the Format property for the same data, the Format property takes precedence when Access displays the data. This means that even if you ve saved an input mask with data, it is ignored when the data is formatted. The characters that can be used in building input masks are shown in the table below: Character Description 0 Digit (0 through 9, entry required; plus [+] and minus [-] signs not allowed). 9 Digit or space (entry not required; plus and minus signs not allowed). # Digit or space (entry not required; blank positions converted to spaces, plus and minus signs allowed). L Letter (A through Z, entry required).? Letter (A through Z, entry optional). A Letter or digit (entry required). a Letter or digit (entry optional). & Any character or a space (entry required). C Any character or a space (entry optional).., : ; - / Decimal placeholder and thousands, date, and time separators. (The actual character used depends on the regional settings specified by double-clicking Regional Settings in the Windows Control Panel.) < Causes all characters that follow to be converted to lowercase. > Causes all characters that follow to be converted to uppercase.! Causes the input mask to display from right to left, rather than from left to right. Characters typed into the mask always fill it from left to right. You can include the exclamation point anywhere in the input mask. \ Causes the character that follows to be displayed as a literal character. Used to display any of the characters listed in this table as literal characters (for example, \A is displayed as just A). Password Setting the InputMask property to the word Password creates a password entry text box. Any character typed in the text box is stored as the character but is displayed as an asterisk (*). (Taken from Access Help files) Page 14

3.9 TASKS 1. Microsoft Access provides two field properties that produce similar results: the Format property and the InputMask property. Use the help to look up the differences between the two. 2. Explore the different formats you can use for different data types in the help facility. 3. Put the following validations and formats on the Student table you created last week: Student last name, first name, Address and course code fields all have to be entered, i.e. they cannot be left blank. The Post Code field should be upper case. Year of the course must be between 1 and 4. The Student first name and last name should both start with an upper case letter and the rest of the name should be a lower case letter. Make sure you test all your validations and formats to make sure they work as you expect them to. 4. Put the following validations on the course table Course code should be four letters maximum and uppercase Number of years on course must be between 1 and 7 Course type must be one of the following: BSc, HND, MSc Again make sure you test all your validations and formats to make sure they work as you expect them to. 5. Add a column to the student table to identify who pays the students fees. The data type should be a Yes/No field called Local Authority pay? Make the Yes/No field display either Authority for yes and Student for no. 6. Add another column to the student table which holds the amount the student has to pay towards their fees. The data type should be numeric Format the column so that the data is displayed as currency, with a pound sign eg. 1,000.00 7. Add a column to the course table to hold whether the course is full-time or parttime. There are two ways to do this try them both. Is one better or easier to use than the other? Page 15