Tutorial 1: Introduction to Tables, Forms, and Menus

Similar documents
Tutorial 2: Queries and Reports

Simple Invoicing Desktop Database with MS Access 2013/2016. David W. Gerbing School of Business Administration Portland State University

Database Tables Lookup Wizard Relationships Forms Subforms Queries Reports

SEE GRADING CRITERIA AT THE BOTTOM. Database Tables Lookup Wizard Relationships Forms Queries Reports

MIS Cases: Decision Making With Application Software, Second Edition. Database Glossary

Microsoft Office Specialist Access 2016

Complete Quick Reference Summary

Access Review. 4. Save the table by clicking the Save icon in the Quick Access Toolbar or by pulling

Creating Reports in Access 2007 Table of Contents GUIDE TO DESIGNING REPORTS... 3 DECIDE HOW TO LAY OUT YOUR REPORT... 3 MAKE A SKETCH OF YOUR

Index. B backing up 76 7

Tutorial 2. Building a Database and Defining Table Relationships

Chapter 5: Hierarchical Form Lab

Designer TM for Microsoft Access

ACCESS. Laboratory Manual. Çankaya University Department of Computer Engineering

Chapter 4: Single Table Form Lab

As your databases continue to evolve, you will need to incorporate advanced queries and reports. This chapter addresses how to create and use action

Getting started with Ms Access Getting Started. Primary Key Composite Key Foreign Key

Access 2013 Introduction to Forms and Reports

Microsoft Access 5: Reports & Other Useful Functions

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

SOFTWARE SKILLS BUILDERS

Microsoft Access XP (2002) Reports

Creating and using reports

Learning About Relational Database By using Microsoft Access 2010

DEVELOPING DATABASE APPLICATIONS (INTERMEDIATE MICROSOFT ACCESS, X405.5)

Word Module 5: Creating and Formatting Tables

Contents. Creating Forms

Access 2003 Introduction to Report Design

Tutorial 1. Creating a Database

Microsoft Access 2007 Level 3

Microsoft Access XP (2002) - Forms. Navigation Wizards Custom Forms Combo Boxes Calculations in Forms Pictures Multitable Input Summary Operations

MIS 2502 Access 2007 Tutorial

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

IT2.weebly.com Applied ICT 9713

Microsoft Excel 2013/2016 Pivot Tables

Using Microsoft Access

MS Access Let s begin by looking at the toolbar and menu of Access.

Links to Activities ACTIVITY 4.1. Links to Activities Links to Activities

Skills Exam Objective Objective Number. Creating crosstab queries Create a crosstab query

Microsoft Office 2010: Introductory Q&As Access Chapter 3

Microsoft Access 2013

Using Microsoft Access

Introduction to Microsoft Office Access 2010

GO! with Microsoft Access 2016 Comprehensive

Let s create another simple report from one of our queries available: Author Age query.

Unit 11.Introduction to Form and Report

Level 6 Relational Database Unit 3 Relational Database Development Environment National Council for Vocational Awards C30147 RELATIONAL DATABASE

Designing Forms in Access

Access 2000 MICROSOFT. Level One Basic. Version N2

Microsoft Office. Access Tutorial Part 2

Microsoft Access 2003 Edition for ECDL Syllabus 4.5 (UK only)

MODULE 5 DATABASES. Content

Microsoft Access 2010

Microsoft Excel Chapter 2. Formulas, Functions, and Formatting

Excel & Business Math Video/Class Project #39 Create Invoices in Excel with Data Validation Drop-down, VLOOKUP & IF Functions

DATA WAREHOUSE BASICS

EXCEL 2007 TIP SHEET. Dialog Box Launcher these allow you to access additional features associated with a specific Group of buttons within a Ribbon.

Schnieder_index.qxd 7/27/05 1:08 PM Page 481 INDEX. Symbols

Microsoft Excel 2010 Handout

Excel Tutorial 1

ENTERING DATA & FORMULAS...

K Hinds Page 1. Information Communication Technology Microsoft Access

Microsoft Access XP Edition for ECDL Syllabus 4.5 (UK only)

USING MICROSOFT ACCESS 2013 Guided Project 7-1

Access Tutorial 6: Form Fundamentals

Enforce Referential. dialog box, click to mark the. Enforce Referential. Integrity, Cascade Update Related Fields, and. Cascade Delete Related

Using Reports. Access 2013 Unit D. Property of Cengage Learning. Unit Objectives. Files You Will Need

Office Access. Intermediate

COMM 391. Objectives. Introduction to Microsoft Access. What is in an Access database file? Introduction to Microsoft Access 2010

Access Intermediate

Microsoft Office 2010: Introductory Q&As Access Chapter 2

PowerPoint Presentation to Accompany GO! All In One. Chapter 13

Access Intermediate

Access: Printing Data with Reports

Microsoft Access XP Queries. Student Manual

Microsoft Access 2016 Intro to Forms and Reports

Introducing Gupta Report Builder

The specific steps to build Wooden Crafts database are here: 1. Create New Database. i. After opening Access, click Blank Desktop Database :

Copyright 2009 Labyrinth Learning Not for Sale or Classroom Use LESSON 1. Designing a Relational Database

ECDL Module 5 REFERENCE MANUAL

CONTENTS INTRODUCTION... 1 DATABASE CONCEPTS... 3

When you pass Exam : Access 2010, you complete the requirements for the Microsoft Office Specialist (MOS) - Access 2010 certification.

Work with Tables and Database Records

Database. Ed Milne. Theme An introduction to databases Using the Base component of LibreOffice

Chapter 4 at a Glance

Microsoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions

Microsoft Access 2010

EXCEL 2003 DISCLAIMER:

Access 2016 Foundation. North American Edition SAMPLE

Preview. MS Access Tutorial. Data Files Available on

Chapter 1: Introduction to Microsoft Access 2003

EXCEL ADVANCED Linda Muchow

Microsoft Access XP (2002) - Advanced Queries

POS Designer Utility

EXCEL 2010 COMPETENCIES

Microsoft Excel for Beginners

Data Should Not be a Four Letter Word Microsoft Excel QUICK TOUR

Fig. 1 Relationship View of Northwind.mdb

Microsoft Excel 2010

Microsoft Access II 1.) Opening a Saved Database Music Click the Options Enable this Content Click OK. *

Transcription:

Tutorial 1: Introduction to Tables, Forms, and Menus This tutorial introduces you to or refreshes your skills using Microsoft Access. In this tutorial, you will implement a simple order entry system for a small computer store called Infinity Computers. Figure 1 is the data model for the Infinity Computers system. Figure 2 summarizes the field properties for the tables in the database. You will implement this order entry system using Microsoft Access. Figure 1: Data Model Customers CustID (pk) CustName CustStreet CustState CustCity CustZip DiscountRate 1 Orders M M OrderID (pk) OrderDate CustID RepID SalesReps SalesRepID (pk) SalesRepName SalesRepPhone CommissionRate 1 1 M OrderItems Products OrderID + ProductID (pk) Quantity M 1 ProductID (pk) Description Price Reorder Discontinued Note: The primary key for OrderItems is a composite key. 1

Figure 2: Field Properties Customers Table/Field Description (not required) Data Type Validation/Settings CustID Customer ID. Text(5) Primary key CustName Business name. Text(35) CustStreet Street address. Text(50) CustCity City. Text(35) CustState State. Text(2) CustZip Zip code. Text(5) DiscountRate Discount rate for customer s orders. Percent 0% to 15% SalesReps Table/Field Description (not required) Data Type Validation/Settings SalesRepID Sales Representative ID. Text(5) Primary key SalesRepName Representative's name - last, first. Text(35) SalesRepPhone Representative's phone number. Format: Text(10) (999) 999-9999. CommissionRate Representative's commission rate. Percent 0% to 10% Products Table/Field Description (not required) Data Type Validation/Settings ProductID Product ID. Text(5) Primary key Description Description of product. Text(50) Price Current sales price. Currency Greater than 0 Reorder Reorder point. Integer 0 or greater Discontinued Product discontinued flag. Boolean Default No Orders Table/Field Description (not required) Data Type Validation/Settings OrderID Order ID. AutoNumber Primary key OrderDate Date order is placed. Date CustID Customer's ID. Text(5) Lookup customer ID RepID Sales representative's ID. Text(5) Lookup sales rep ID OrderItems Table/Field Description (not required) Data Type Validation/Settings OrderID Order ID. Long Integer Composite ProductID Product ID. Text(5) primary key Quantity Quantity ordered. Integer Greater than 0 Notes: For Text fields, set the Field Size as shown in parentheses. For Percent fields, use Number and Field Size = Single. For Boolean fields, use Yes/No. For Lookups, use the Lookup Wizard and do not change field properties set by the wizard. 2

Define Tables Open OrdEnt1.mdb. Click the Tables tab to display the tables in the database. The SalesReps table is already in the database. Start by defining the Customers table. On the Tables tab, click New to create a new table. Select Design View (Figure 3). Figure 3: New Table Given a database design specification, the process of defining a new table is straightforward. Figure 1 and Figure 2 represent the design for the Infinity Computers database. Microsoft Access provides a Table Design View that consists of two major sections. As shown in Figure 4, the upper panel is for specifying the fields in the table and the lower panel is for specifying the specific properties associated with each field. Each field has a field name and data type. The field name determines the reference to the field. The data type defines the values the field may hold, as well as the types of operations allowed using the field. Like Microsoft Access, most DBMS support a variety of data types, including text, number, date/type, Boolean (Yes/No), currency, as well as others. The field description is optional. In addition to the name and data type, each field has a number of other properties. Microsoft Access assigns default values to properties based on the indicated data type. In some cases, you may need to change the default properties and set additional properties. As shown in Figure 4, the DiscountRate field holds a discount percentage. The base data type is Number. The Field Size is Single, which represents the smallest floating-point (decimal) value provided by Microsoft Access. The Format is Percent so that the field appears as a percentage with the proper symbol. Generally, the Decimal Places property should remain set to Auto; only change this property if there is a compelling reason. The Validation Rule property provides a way to verify the value entered by the user. The example illustrates how to use this property; specify an expression that limits the values allowed. In this case, the expression is >=0 And <=0.15. This validation rule constrains the value to be between 0 and 15%. The Validation Text property defines the error message displayed by Microsoft Access if the user enters 3

an invalid value. If you do not specify this value, Microsoft Access displays a message; however, this message is often difficult for users to understand. Figure 4: Fields and Field Properties Save Button Primary Key Button Fields Field Properties Define the fields for the Customers table. For each Text field, set the Field Size property as shown in Figure 2. Each table has a primary key that consists of one or more fields. All fields comprising the primary key should be adjacent. Select the field or fields by clicking and dragging the mouse to select the fields. Click the Primary key button to set the primary key. Set CustID as the primary key for the Customers table. Once you have defined all of the fields and defined the primary key, click the Save button to save the table definition. Enter the table name (Figure 5). Click Ok. Figure 5: Table Name 4

Using the Lookup Wizard Continue defining tables starting with the Orders table. Enter the OrderID and OrderDate fields. For the CustID field, we want to use a drop-down combo box that lists the customers (a lookup list) in the database. To do this, set the data type to Lookup Wizard (Figure 6). Figure 6: Start Lookup Wizard The Lookup Wizard enables you to establish a set of values that a field may take. The values may come from another table, or you may enter the values (Figure 7). To make a system flexible and extensible, the values generally come from a table. Select the first option to pull values from a table. Click Next. Figure 7: Lookup Sources 5

The Lookup Wizard displays a list of the tables in the database (Figure 8). At this point, the data source for a lookup list may be a table or query. In addition, before you can define the lookup list, you must define the table that provides the data for the lookup list. Select the Customers table and click Next. Figure 8: Available Tables Next, define the fields in the lookup list (Figure 9). When defining a lookup list, include the primary key of the source table first and then define enough fields so that the user may determine the appropriate entry to select from the list. As shown, the CustID lookup list includes the customer s name and city; this enables the user to choose the correct customer. Click Next. Figure 9: Fields in the Lookup List 6

As shown in Figure 10, you should generally hide the column storing the key field from the source table since this value is typically not useful when selecting one of the items in the list. You may also resize the columns in the list as appropriate so that they are wide enough for the user to see complete descriptions. Once you have modified the settings as desired, click Next. Figure 10: Lookup List Settings The last step in defining a lookup list is to specify the name of the field in the new table that stores the primary key value for the selected item in the lookup list (Figure 11). The default value is the name you assigned to the field before starting the Lookup Wizard. Unless you wish to change this name, click Finish. Figure 11: Lookup Field Name The Lookup Wizard must save the new table before completing the process of building the lookup list. If you have not already saved the table, you must enter the table s name when prompted. In addition, if 7

you have not specified the new table s primary key yet, you will see a message asking you if you want Microsoft Access to create the primary key. Click No since you can assign the primary key later. Once the Lookup Wizard has finished defining the lookup list, you can view the lookup list setting on the Lookup tab in the Field Properties section (Figure 12). Figure 12: Lookup List Specification When defining a field as a lookup list, NEVER modify the field size on the General tab. If you do so, you may cause the lookup list not to function properly. Define the RepID field using the Lookup Wizard. Include the SalesRepID, SalesRepName, and SalesRepPhone fields in the lookup list. Set the primary key and save the Orders table. Use the Table Design View to create the remaining tables. Set the validation rules and other field properties as needed. Establish Relationships among Tables Once you have defined the tables, click the Relationships button (Figure 13). Figure 13: Establish Relationships Relationships Button 8

The Relationship View displays the relationships among the tables (Figure 14). As you created lookup lists, Microsoft Access automatically established relationships among the tables used for the lookup lists. Right now, a couple tables in the database are not related; in a properly defined database, there exists a direct or indirect relationship among all tables. Figure 14: Relationship View Show Table Button Click the Show Table button to display a list of tables in the database. Select the OrderItems table and click Add. Select the Products table and click Add. Click Close to hide the list of tables. Figure 15: Tables in the Relationship View 9

As shown in Figure 15, no relationship connects the tables you just added to the other tables. From the data model (Figure 1), the OrderItems table relates to the Orders table and the Products table. To relate OrderItems to Orders, click and drag the OrderID field in Orders to the OrderID field in OrderItems. Notice that the mouse pointer changes when you hover it over the OrderItems table; this indicates that you are establishing a relationship. Figure 16: Edit Relationships When you release the mouse button while hovering over the OrderID field in OrderItems, Microsoft Access displays the Edit Relationships dialog. Check the Enforce Referential Integrity check box. The Referential Integrity constraint is important in systems because it dictates that the value assigned to a foreign key must match the value assigned to a primary key in the related table. In this case, it dictates that any OrderID value assigned in the OrderItems table match an OrderID value in the Orders table. This prevents the user from entering an order item without a corresponding order. Click Create to establish the relationship. Microsoft Access will permit you to establish incorrect relationships. In Figure 17, the relationship shown uses the ProductID and Description fields to relate OrderItems and Products. This is not a valid relationship since the two fields store different types of data values. Unfortunately, this error is difficult to detect until the user attempts to enter data. When establishing relationships, be sure to drag and drop the primary key onto the foreign key. 10

Figure 17: Incorrect Relationship In Figure 18, the line connecting Orders and OrderItems is different from the line connecting the other tables because the relationship enforces referential integrity. To update an existing relationship to enforce referential integrity, simply double click the line between the related tables and set the Enforce Referential Integrity constraint. Figure 18: Relationship with Referential Integrity Enforced Update the relationship between Customers and Orders to enforce referential integrity. Update the relationship between SalesReps and Orders to enforce referential integrity. Define a relationship between OrderItems and Products that enforces referential integrity. Once you have defined the relationships, close the Relationship View. Save the changes when prompted. 11

Form and Subform Create a form and subform to enter orders. Figure 19 shows what the finished form will look like after you complete all modifications. Figure 19: Completed Orders Form Generating the Initial Form using the Form Wizard Click the Forms tab. Click New, select Form Wizard, and specify the Orders table as the initial data source (Figure 20). 12

Figure 20: Form Wizard Click OK to start the Form Wizard. Add all fields from the Orders table to the form by moving the fields to the Selected Fields list (Figure 21). Figure 21: Initial Fields on Form Use the Tables/Queries drop-down list to add the Customers table as a data source (Figure 22). 13

Figure 22: Selecting an Additional Table in the Form Wizard Add the DiscountRate field to the Select Fields list. Add all fields from the OrderItems table to the form. Add the Price field from the Products table. Click Next. Since the purpose of this form is to enter orders, select the option to view the data by orders (Figure 23). Also, select the option to create a form with a subform. Figure 23: View by Order Microsoft Access can display the data in the subform in a variety of ways (Figure 24). For a transaction data-entry form, the two main options are Tabular, where each line item displays similar to a horizontal 14

form, or Datasheet, where the line items display similar to a table in Table View. Select Datasheet and click Next. Figure 24: Subform View The next step is to specify the appearance of the form (Figure 25). You may click on the various options to preview each style. Initially, a good practice is to select a simple style such as Standard. After selecting a style, click Next. Figure 25: Form Style The final step is to name the form and subform objects (Figure 26). Microsoft Access automatically assigns names to these two objects. Click Finish to generate the form and subform. 15

Figure 26: Form and Subform Names Microsoft Access displays the initial form (Figure 27). Figure 27: Initial Form Compute Order Item Extended Price and Order Subtotal Open the OrderItems subform in Design View so that you can modify the subform. Figure 28 shows common controls used in the remainder of the tutorial. 16

Figure 28: Common Design View Controls Field List Button Properties Button View Button (Switch between Form View and Design View) Form Selector* Label Button Text Box Button *The Form Selector plays an important role when editing a form with a subform. To edit properties and program code for the main form, activate the main form s Selector, as shown in Figure 28. Activate the subform s Selector to edit properties and program code for the subform. Display the properties for the form. Edit the Record Source property by clicking on the record source value and then clicking the Build button beside the Record Source property s text box. Edit the record source query to look like Figure 29. Figure 29: OrderItems Subform Record Source Add the Ext Price derived field to the query. To create the Ext Price field, type the following in the Field cell of the first empty column: Ext Price:Quantity*Price 17

After typing the equation, use the Tab key to move to the next column. Notice how Microsoft Access modifies the equation to look like Figure 29. Close the Query Builder window and choose Yes when prompted to update the query. Expand the Detail section by dragging the top of the Footer divider down. In Design View, click the Field List button. Drag and drop the Ext Price field beneath the Price field (Figure 30). Figure 30: Adding a Field to a Form Ext Price Field Drag the bottom of the Footer section down to make room to add a text box. Click the Text Box button and add a text box to the footer (Figure 31). In the text box, type the expression to sum the values for the Ext Price field displayed in the Detail section. This sets the field s Control Source property to: =Sum([Ext Price]) The text box must be in the footer so that the formula applies to all records displayed in the Detail section. Why is Ext Price enclosed in square brackets? Set the Name property for the new text box to Subtotal so that you can easily access the new field in the main form. Each control on a form falls into one of three categories: bounded, calculated, or unbounded. On the subform, the bounded controls are OrderID, ProductID, Quantity, and Price since their control sources are fields in tables. The calculated controls are Ext Price and Subtotal text box since their control sources are expressions, not fields in tables. Any labels, buttons, and other controls are unbounded since their values do not come from fields in tables and are not expressions. Your subform should look similar to Figure 31. 18

Figure 31: Subtotal Computation Subtotal Field Save and close the subform. Display Subtotal on the Main Form Open the Orders form in Design View. Rearrange the fields on the form so the DiscountRate text box is below the subform, but not in the Footer. Set the format property for the DiscountRate text box to Percent. View the record source for the form and verify that it looks similar to Figure 32. Figure 32: Orders Form Record Source 19

Add a text box to the main form below the subform. Set the Control Source property to: =[OrderItems Subform].Form!Subtotal One way to set the value of the Control Source property is to type the value in the property s text box. If you know the exact name of the subform and field on the subform, this approach works fine. If you are uncertain of the name of the subform or field, another you can use the expression builder feature to construct the reference to the field. Display the properties for the new text box and select the Control Source property (Figure 33). Click the Build button to access the Expression Builder. Figure 33: Text Box Properties Build Button In the Expression Builder (Figure 34), select the Order Items subform by double clicking the plus sign (+) beside Forms, Loaded Forms, and then Orders. Click Order Items Subform to access to the fields on the Order Items subform. 20

Figure 34: Form Selection in Expression Builder Scroll down the field list and double click the Subtotal field to build an expression that accesses the Subtotal field on the subform (Figure 35). Click Ok to set the value of the Control Source property and return to the properties list. Figure 35: Subtotal Field Reference In the properties list, name the text box OSubtotal and set the display format to Currency. 21

Perform Calculations on a Form Add a text box below the OSubtotal text box. Set the Control Source property to: =OSubtotal*DiscountRate Name the text box ODiscount and set the display format to Currency. Finally, add a text box below the ODiscount text box. Set the Control Source property to: =OSubtotal-ODiscount Name the text box OTotal and set the display format to Currency. Save the changes to the Order form. Switch to Form View. Your form should look similar to Figure 19, but not identical (yet). Switch back to Design View to rearrange fields and make any other changes needed. To make a field label more meaningful than the field name in the table, click the label and type a new, descriptive value in the label s Caption property. We will cover other form settings in future tutorials. Save the changes. Close the form. Generate Simple Forms Use the Forms Wizard to create these forms to maintain customers, sales representatives, and products. Keep your forms simple. Figure 36 is a sample form to enter product data. Figure 36: Sample Products Form Enter Data Using the forms you created, enter the customer data (Figure 37), product data (Figure 38) and sales representative data (Figure 39). Figure 37: Customers Data 22

Figure 38: Products Data Figure 39: Sales Representatives Data Using your Orders form, enter the sample orders shown in Figure 19 and Figure 40. Figure 40: Sample Order 2 Create a Switchboard Menu Read the information in the Microsoft Access Help System about switchboard menus. Use the switchboard manager (Tools Database Utilities Switchboard Manager) to create and configure a switchboard menu that provides easy access to the forms you have just created. Configure 23

the forms to open in Edit mode. If you configure a form to open in Add mode, you will only be able to add new records, not edit existing records.) Figure 41: Sample Switchboard Menu 24