31
Using Microsoft Office 2003 Introduction to Access Handout INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles Version 1.1 Summer 2005 Contents Stages of Using Access ...................................................................................................................3 Downloading a Data File ...........................................................................................................3 Starting MS Access 2003 ...........................................................................................................4 Using Access ...................................................................................................................................4 The Access 2003 Interface .........................................................................................................4 The Database Window ...............................................................................................................5 Database Objects........................................................................................................................5 Opening an Exiting Database .......................................................................................................6 Creating a New Database ..............................................................................................................7 Designing Tables .......................................................................................................................7 Tables ..............................................................................................................................................8 Creating a Table Using the Table Wizard..................................................................................8 Creating a Table Using Design View ......................................................................................10 Using the Datasheet View........................................................................................................12 Queries ..........................................................................................................................................13 Creating a Query Using Simple Query Wizard .......................................................................13 Creating a Query in Design View ............................................................................................14 Forms ............................................................................................................................................15 Creating a Form Using the Form Wizard ................................................................................15 Creating a Form in Design View .............................................................................................17 Using the Toolbox Toolbar to Design a Form .........................................................................19 Reports ..........................................................................................................................................19 Creating a Report Using Report Wizard ..................................................................................20 Creating a Report using Design View .....................................................................................23 Printing Reports ...........................................................................................................................26 Selecting Page Setup Options ..................................................................................................26 Printing in Access ....................................................................................................................26 Appendix: Setting Table Attributes ..........................................................................................28 Assigning Data Types ..............................................................................................................28 Adding Field Description.........................................................................................................28 Setting a Primary Key ..............................................................................................................28 Using Field Properties..............................................................................................................29 Limiting Field Size ..................................................................................................................29 Setting Number Formats ..........................................................................................................30 Setting Date/Time Formats ......................................................................................................30

Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Using Microsoft Office 2003 Introduction to Access Handout

INFORMATION TECHNOLOGY SERVICES California State University, Los Angeles

Version 1.1 Summer 2005

Contents

Stages of Using Access ...................................................................................................................3 Downloading a Data File ...........................................................................................................3 Starting MS Access 2003...........................................................................................................4

Using Access ...................................................................................................................................4 The Access 2003 Interface.........................................................................................................4 The Database Window...............................................................................................................5 Database Objects........................................................................................................................5

Opening an Exiting Database .......................................................................................................6

Creating a New Database ..............................................................................................................7 Designing Tables .......................................................................................................................7

Tables ..............................................................................................................................................8 Creating a Table Using the Table Wizard..................................................................................8 Creating a Table Using Design View ......................................................................................10 Using the Datasheet View........................................................................................................12

Queries ..........................................................................................................................................13 Creating a Query Using Simple Query Wizard .......................................................................13 Creating a Query in Design View............................................................................................14

Forms ............................................................................................................................................15 Creating a Form Using the Form Wizard ................................................................................15 Creating a Form in Design View .............................................................................................17 Using the Toolbox Toolbar to Design a Form.........................................................................19

Reports ..........................................................................................................................................19 Creating a Report Using Report Wizard..................................................................................20 Creating a Report using Design View .....................................................................................23

Printing Reports...........................................................................................................................26 Selecting Page Setup Options ..................................................................................................26 Printing in Access ....................................................................................................................26

Appendix: Setting Table Attributes ..........................................................................................28 Assigning Data Types ..............................................................................................................28 Adding Field Description.........................................................................................................28 Setting a Primary Key..............................................................................................................28 Using Field Properties..............................................................................................................29 Limiting Field Size ..................................................................................................................29 Setting Number Formats ..........................................................................................................30 Setting Date/Time Formats ......................................................................................................30

Page 2: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Introduction to Microsoft Access 2003 - 2

Setting Yes/No Formats...........................................................................................................30 Setting Default Values .............................................................................................................31 Setting Validation Rules and Text ...........................................................................................31

For additional written instructional guides, visit us @ http://www.calstatela.edu/handouts

Page 3: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Introduction to Microsoft Access 2003 Microsoft Access is a computerized Database Management System (DBMS) that allows efficient data storage and retrieval as well as enhanced data presentation. Databases store information related to a particular topic or purpose. An illustration of a database is a file cabinet containing diverse information in different drawers. Another example of a database is an address book which stores information such as last name, first name, home address, telephone number, cell phone number, and email address. The information can be organized by any of the different categories.

The difference between a paper or document-based database and Access is the efficiency and effectiveness that a computerized database provides. Users are able to store, retrieve and present information effectively using Access. Computerized databases are cost-effective because large amounts of information can be maintained in a personal computer for an indefinite period of time.

This guide is an introduction to Access 2003 and illustrates the basic functions the program offers. Users can either start from the beginning for an overview of Access or choose specific topics from the table of contents.

Stages of Using Access Using Access involves several stages: starting the program, storing, retrieving, and presenting data. Starting Access familiarizes the user with the location of the program and introduces the interface. Before information can be managed with Access the database must be created. This includes defining a table(s) that will include field names where information can be stored. Once information is stored in a table, queries provide a data retrieval mechanism for purposes such as sorting, updating, and deleting records. Finally, data can be retrieved from tables or queries and presented in a form for efficient data entry with a professional appearance or a report for a summary of data suitable for printing.

DOWNLOADING A DATA FILE Follow the steps below to download the Access data file that accompanies this handout.

To download files from the Internet: 1. Double-click the Internet Explorer

icon on the desktop. 2. Type the following address in the

website Address bar to download the file: [ftp://ftp.calstatela.edu/pub/its/Trng_Sample.mdb]

3. Press the [Enter] key. The File Download dialog box opens (see Figure 1).

Figure 1 - File Download Dialog Box

4. Click the Save button. The Save As dialog box opens (see Figure 2). 5. Select a drive from the Save in: drop down list where the data will be stored. 6. Use the default file name and file type in the File name: and Save as type: textboxes. 7. Click the Save button.

Introduction to Microsoft Access 2003 - 3

Page 4: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 2 – Save As Dialog Box

STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them.

To open Access 2003 in the Open Access Computer Labs: 1. Click the Start menu at the bottom left corner of the screen. 2. Select the All Programs option. 3. Select the Microsoft Office 2003 folder. 4. Click the Microsoft Access application icon.

!NOTE: A shortcut to starting Access is to double-click the Microsoft Office 2003 folder on the desktop then double-click the Microsoft Access icon.

Using Access Because of the nature of any DBMS, the Access program is significantly different from the other applications in the Microsoft Office 2003 suite. The following sections explain many of these differences and how to function within the Access environment.

THE ACCESS 2003 INTERFACE Once started, the Microsoft Access interface opens as shown in Figure 3. The Access 2003 interface consists of two windows: the Application window and the Database window. The Application window contains a Title bar, Menu bar (very common in other applications), Table toolbar, and Task Pane. The Database toolbar provides access to commonly used features such as save, print, spelling and grammar check, cut, copy, paste, format painter, undo, properties, and object. The Task Pane is displayed on the right side of the Application window. It provides options for managing database file(s) such as: opening an existing file, creating a new blank file, creating a new file from an existing file or creating a new file by using a template. Once a database is opened by clicking on one of the options, the Task Pane will automatically close.

Introduction to Microsoft Access 2003 - 4

Page 5: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 3 - Microsoft Access Interface

!NOTE: The Task Pane replaces commonly-used dialog boxes. For example, when selecting New… from the File menu to create a new database, the New File pane will appear in the task pane. In previous versions of Access, a separate New File dialog box would appear.

THE DATABASE WINDOW When a database is opened, the Database window opens within the Access Application window. The Database window contains a Title bar, Tool bar, Objects bar, and Groups bar as shown in Figure 4. The Objects bar contains seven object buttons: Tables, Queries, Forms, Reports, Pages, Macros, and Modules. The Groups bar also contains a Favorites button which can be used to add new group folders.

Figure 4 – Database Window

DATABASE OBJECTS Access consists of seven objects that are used to store, manipulate, and retrieve information within the database. The different types of objects are described in Table 1.

Introduction to Microsoft Access 2003 - 5

Page 6: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Table 1 - Definitions of Objects Object Type Button Object Purpose

All data is the database is stored in tables. Access uses tables to display the raw data in records (rows) and fields (columns). Data usually consists of information of a particular category such as students, courses, customers, etc.

A query is a question asked about the data in the database. Queries allow defining criteria to retrieve specific information to display or sort.

A form allows displaying, entering, editing, and printing formatted data one or several records at a time.

A report is a design for printed data. Data is summarized using the report function. Specific information can be retrieved for display such as a list of mailing labels or class grades. Reports can also perform math operations and calculate summaries.

A page is a data Access Web page used for viewing and working with Microsoft Access databases over the Internet or an intranet.

A macro is a stored set of commands that can be repeated as a unit to automate database functions.

Modules use the Visual Basic Applications programming language to edit or add programming code that can further customize and enhance database functions.

Opening an Exiting Database An existing Access database may be organized into any number of the different types of database objects.

To open an existing database: 1. Click the Open button on the Standard toolbar. The Open dialog box opens (see

Figure 5).

Figure 5 – Open Dialog Box

2. Click the Look in: drop-down arrow and select the drive where the file is stored.

Introduction to Microsoft Access 2003 - 6

Page 7: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

3. Select the file to open. 4. Click the Open button.

!NOTE: In this exercise, locate the file “Trng_Sample.mdb” and open it. The Database window will open (see Figure 4).

Creating a New Database A database file is a container for all the objects in that particular database. When creating a new database, new objects must be created. The various wizards and templates can be utilized to speed the process of creating objects.

To create a new database: 1. Select the File menu from the Menu bar then select New…. The New File task pane

opens (see Figure 3). 2. In the New section select Blank Database…. The File New Database dialog box opens

(see Figure 6). 3. Click the Save in: drop-down arrow to select the drive where the file will be saved. 4. Enter a name in the File name: text box. 5. Click the Create button.

Figure 6 – File New Database Dialog Box

DESIGNING TABLES After creating the database, the next step is to design a table(s) and begin entering data so that reports, statistics, labels, and other items can be generated.

There are five basic steps to designing a table: 1. Determine the output requirement, such as the information that will be retrieved from the

database. 2. Determine how many tables will be need for the data and the kind of data for each table. 3. Select the fields to include along with data properties such as field size and type. 4. Set the primary keys in each table and determine the relationship(s) between tables. 5. Enter data and identify fields at the top of the structure to improve performance.

Introduction to Microsoft Access 2003 - 7

Page 8: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Tables The basic building block of a database is the table. A table consists of fields and records. The intersection of a field and a record is a data cell where information relevant to that particular field for that particular record is entered. Creating a table is always the precursor to other objects such as queries, forms, and reports because each object uses the fields and records from a table as the basis for its output.

There are two ways to create a table: using the Design View or using the Table Wizard. The Design View creates a new table from scratch and provides the most control over the design of the table. Field names can be assigned the data type property set appropriate to the data that the filed will contain (see Appendix). Field names and data types can be modified at any stage of creating a table. In contrast, the Table Wizard provides predefined table options as a matter of convenience. With the options in the Table Wizard, modifications of field names and data types are only possible after creating a table, and then only by working in the Design View.

Select the method of table creation that is best suited to the user. This section will demonstrate how to create a table using both methods.

CREATING A TABLE USING THE TABLE WIZARD The Table Wizard can be used to lead the user through the steps to create a new table similar to the table created using the Design View. The Table Wizard contains a set of models or templates of business-related and personal-use tables. Select the type of table to create, and then select the predefined fields to include in the table.

To create a table using the Table Wizard: 1. Click the Tables button on the Objects bar. 2. Click the New button . 3. Select Table Wizard from the list box in the New Table dialog box. 4. Click the OK button. The Table Wizard dialog box opens (see Figure 7).

Figure 7 - Table Wizard Dialog Box

5. Select the Business option button. 6. Select “Contacts” in the Sample Tables: list box. 7. Select the desired field names in the Sample Fields: list box by double-clicking the field

name or by clicking the single right-pointing arrow between two list boxes. Either action

Introduction to Microsoft Access 2003 - 8

Page 9: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

will move the field name(s) to list box in the Fields in my new table: one by one. (For this example select “FirstName,” “LastName,” “Address,” “City,” “HomePhone,” and “Title”).

8. Click the Next button. 9. Enter [Contact2] in the What do you want to name your table? text box (see

Figure 8). 10. Click the No, I’ll set the primary key. option button. 11. Click the Next> button.

Figure 8 – Naming the Table Figure 9 - Setting the Data Type for Primary Key

12. Select “LastName” from the What field will hold data that is unique for each record? drop-down list (see Figure 9).

13. Select the Numbers and/or letters I enter when I add new records option button. 14. Click the Next> button. 15. Click the Next> button (see Figure 10).

Figure 10 – Setting Relationships Figure 11 – Enter Data Directly to Table

16. Select the Enter data directly into the table. option button (see Figure 11). 17. Click the Finish button.

!NOTE: The Datasheet View will become active for the table just created (see Figure 12).

Introduction to Microsoft Access 2003 - 9

Page 10: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 12 - Contact2 Table Created by Table Wizard

Enter the following records into the table: Last Name First Name Title Address City Home Phone Cruz Thomas Supervisor 5151 State University Drive Los Angeles (323) 343-3700 Fred Ari Assistant 516 Wilshire Bl Los Angeles (818) 555-1234 Kuramoto Jenny Trainer 123 Vermont Bl Los Angeles (818) 237-1818 Padilla Jose Trainee 9812 Atlantic Bl Monterey Park (626) 545-2314 Kim Kathy Intern 213 San Gabriel Alhambra (626) 589-7810 Nguyen Sandy Supervisor 879 Main Street Alhambra (626) 374-7733

CREATING A TABLE USING DESIGN VIEW As previously mentioned, a table created in Design View will provide the most control over the design of a database. Assign field names first then specify the field property in the Property pane. If field names are not assigned, Access will give the default name a field number.

To create a table in Design View: 1. Open the “Trng_Sample.mdb” file. 2. Click the Tables button on the Objects bar (see Figure 13). 3. Click the New button. The New Table dialog box opens (see Figure 13). 4. Select “Design View” in the list box on the New Table dialog box. 5. Click the OK button. The Design View window opens (see Figure 14).

Figure 13 - New Table Dialog Box

Introduction to Microsoft Access 2003 - 10 Figure 14 – Table Design View Window

Page 11: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

!NOTE: The Design View window is split into two panes (see Figure 14). The top pane is the Design Grid pane. Use the rows and columns to enter field names, data types, and field descriptions. The bottom pane is the Field Properties pane. If the specific information for each field is known, the properties may be specified as desired. For detailed descriptions of field properties provided by Access see Table 4.

6. Type the following field names in the “Field Name” column [Last Name], [First Name], [Class Standing], and [Phone Number].

!NOTE: The following apply when assigning field names: • Field names can be up to 64 characters in length and be composed of letters, numbers,

symbols, and spaces. • Field names cannot include: periods (.), exclamation points (!), quote marks (“ “),

brackets ([ ]) or accent graves (`). • Field names cannot start with a blank space. • Making the field names descriptive and meaningful can help with data entry and data

retrieval.

7. Designate the Data Types for each field. The default data type is “Text.”

!NOTE: There are ten different Data Types to select from. Table 3 in the Appendix describes the features of each type.

8. The “Description” column is optional. It allows entry for an explanation or description of the type of information entered.

9. Click the Datasheet View button on the Standard toolbar. The Microsoft Access message box appears as shown in Figure 15.

10. Click the Yes button to save the table. The Save As dialog box will appear as shown in Figure 16.

Figure 15 – Microsoft Access Message Box

Figure 16 - The Save As Dialog Box

!NOTE: Access will ask the user to set a primary key. If no primary key is selected Access will create an index as the primary key.

11. Type [English Class] in the Table Name: text box and click the OK button to save the table.

Introduction to Microsoft Access 2003 - 11

Page 12: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Table Datasheet View Design View

Figure 17 - Table Datasheet View and Table Design View

12. Enter the necessary data under each field name (“Last Name,” “First Name,” “Class Standing,” and “Phone Number”). The Datasheet View and Design View will be very similar to the one shown in Figure 17.

USING THE DATASHEET VIEW After creating a table, the Datasheet View can be used to manage information entered into the table. The Datasheet View window is useful for entering, editing, or deleting records. Figure 18 displays contents of the Datasheet View window and how to navigate it.

Figure 18 – Datasheet View Window

Data can be entered into a table while in Datasheet View by clicking the cursor in the field and typing the relevant data. If data needs to be edited, select the field in the record and make the necessary changes. Fields can be navigated by using the four arrow keys on the keyboard. Deleting a record is accomplished by selecting the entire record (click the Record Selector button on the left edge of the record) and either pressing the [Delete] key or by clicking the Delete button on the Standard toolbar.

!NOTE: Clicking the Delete button or pressing the [Delete] key will activate a Warning box requesting confirmation before deleting the selected record(s). This is necessary because record deletion is permanent. Deleted records cannot be recovered.

Introduction to Microsoft Access 2003 - 12

Page 13: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Queries A query is a request to select specific information from a table(s). Queries do not hold any data; they hold or save the criteria used to select the data from the table(s). If the table related to a query is deleted (intentionally or unintentionally) the query cannot be run again.

Queries can be used to analyze data, display specific information, and serve as the basis for forms or reports. A query can be used to specify desired fields and criteria to display information from a table, related tables, or other queries. This section will demonstrate how to create a query using the Design View or the Query Wizard.

!NOTE: Queries are different from tables even though the interfaces of tables and queries are very similar to each other. A table must exist before a query can be created.

CREATING A QUERY USING SIMPLE QUERY WIZARD The Simple Query Wizard allows creation of queries without utilizing the Query Design window. The Simple Query Wizard uses pre-defined, automated steps similar to those found in other Microsoft application wizards. The Simple Query Wizard lists names of objects (tables and queries) in a database and field names in a desired object.

To create a query using the Simple Query Wizard: 1. Click the Queries button in the Objects bar in the Database window. The New Query

dialog box opens (see Figure 21). 2. Double-click the Create Query by Using Wizard icon . The Simple

Query Wizard dialog box opens (see Figure 19). 3. Select the “Contact2” table from the Tables/Queries drop-down list. 4. Double-click “LastName,” “FirstName,” and “Title” in the Available Fields: list box or

select the same fields and clicking the single right-pointing arrow. The fields selected are moved to the Selected Fields: list box (see Figure 19).

Figure 19 – Simple Query Wizard

5. Click the Next> button. 6. Enter [Contacts Query2] in the What title do you want for your query? text box (see

Figure 20). 7. Select the Open the query to view information option button.

Introduction to Microsoft Access 2003 - 13 8. Click the Finish button.

Page 14: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 20 – Query Wizard

CREATING A QUERY IN DESIGN VIEW Creating a query in Design View gives the user control over the design of a query including adding or deleting criteria to selected records and sorting results in the record set. The Query Design window consists of a top and bottom pane. The top pane displays the table(s) used in the query. The fields in the table(s) are listed so that those used in the query can be specified. When displaying field lists, more than one table can be selected. The bottom pane specifies the fields used in the query, criteria to retrieve the desired information, sort parameters in the query (ascending or descending order), and whether a field is displayed when the query is run.

Figure 21 – New Query Dialog Box Figure 22 – Show Table Dialog Box

To create a simple query using Query Design window: 1. Click the Queries button in the Objects bar of the Database window. 2. Click the New button . The New Query dialog box opens (see Figure 21). 3. Select “Design View.” 4. Click the OK button. The Query Design window and the Show Table dialog box open

(see Figure 22). 5. Select the Tables tab in the Show Table dialog box. 6. Select the “Contact2” table. 7. Click the Add button to add the table into the Query Design window. 8. When all tables and other queries have been added to the Query Design window, click the

Close button to close the Show Table dialog box.

Introduction to Microsoft Access 2003 - 14

9. Select the desire fields by double-clicking “Last Name,” “First Name,” and “Title” from the “Contacts2” table list box (see Figure 23).

Page 15: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 23 – Query Design View

10. Click the Datasheet View button on the application toolbar.

Contact2 Table Before Running a Query After running a query with three fields

Figure 24 – Running a Query and RecordSet

!NOTE: In this example only the three selected fields are displayed. Fields from more than one table may be displayed at a time.

Forms Forms can be used to view and edit data in a record. All fields for one record can be viewed at the same time eliminating the need to scroll to display all the fields in a table. Forms can also be used to present data in a more attractive and efficient format than a datasheet. Forms can also be used to display data from multiple, related tables.

Forms can be created from either the Form Design window or by using the Form Wizard. When creating a form, it is important to remember that a table is the basis for all objects including forms; forms cannot be created without a pre-existing table.

CREATING A FORM USING THE FORM WIZARD The Form Wizard contains many options such as layout of the data (“Columnar,” “Tabular,” “Database,” or “Justified”), the tables used, selected displayed fields, and the styles of the form. Use of the Form Wizard is recommended until the user is comfortable using the Design View.

Introduction to Microsoft Access 2003 - 15

Page 16: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

To create a form using the Form Wizard: 1. Click the Forms button on the Objects bar in the Database window. 2. Click the New button. 3. Select Form Wizard from the New Form dialog box (see Figure 25). 4. Select “Contacts2” from the Choose the table or query where the object’s data comes

from: drop-down list. 5. Click the OK button.

Figure 25 – New Form Wizard Dialog Box

6. Select the object(s) from the Tables/Queries drop-down list (see Figure 26). 7. Select a field from the Available Fields: list box and move it to the Selected Fields: list

box by using the right-pointing arrow (for this example move “LastName,” “Title,” “Address,” “City,” and “FirstName”).

8. Click the Next> button.

Figure 26 – Form Wizard: Selecting Fields

9. Click the Columnar option button. 10. Click the Next button (see Figure 27).

Introduction to Microsoft Access 2003 - 16

Page 17: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 27 - Form Wizard: Selecting Layout Figure 28 - Form Wizard: Selecting Style

11. Select “Standard” in the list box as the style for the form. A preview displays to the left. 12. Click the Next button (see Figure 28). 13. Enter “Contacts3” for the name of the form in the What title do you want for your form?

text box. 14. Click the Finish button (see Figure 29). The new form created with the Form Wizard

dialog box opens (see Figure 30).

Figure 29 - Form Wizard: Naming Form Figure 30 - Form Created by Form Wizard

CREATING A FORM IN DESIGN VIEW Unlike creating tables and queries using their respective Design Views, creating a form using the Design View requires skills for clicking and dragging form controls, as well as aligning bound and unbound controls.

To create a form using the Form Design window: 1. Click the Forms button on the Objects bar in the Database window. 2. Click the New button. The New Form dialog box opens (see Figure 31). 3. Select “Design View” from the list box. 4. Select “Contacts” from the Choose the table or query where the object’s data comes

from: drop-down list. 5. Click the OK button.

Introduction to Microsoft Access 2003 - 17

Page 18: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 31 – New Form Dialog Box

!NOTE: The Form Design window, Toolbox toolbar (undocked), and Field List box (for the “Contacts2” table) should all open (see Figure 33). The Form Design window is where fields for the selected table are selected and dragged onto the design grid. Once the fields are placed, modifying the properties of fields such as size, alignment, shape, and insertion of image files is a relatively easy process.

6. From the “Contacts” table Field List box, click and drag the following fields to the design grid: “Last Name,” “First Name,” “Title,” “Address,” “City,” and “Postal Code.” If the field that was dragged is not properly aligned, sized, or needs to be moved, click the unbound control and the bound control to adjust their size, alignment, or placement (see Figure 32).

Figure 32 – Aligning Controls

!NOTE: A bound control is one where the content displayed is directly tied to a field in a table or query (such as a text box). An unbound control is not tied to any other object. The content displayed by an unbound control is controlled by the user.

7. Click the View button on the Form Design toolbar. The form should change to the Form View as shown in Figure 33.

8. Click the Save button. 9. Save the form as “Contacts2.”

Introduction to Microsoft Access 2003 - 18

Page 19: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Form Design Window Form View

Figure 33 - Form Design Window and Form View

USING THE TOOLBOX TOOLBAR TO DESIGN A FORM The Toolbox toolbar (see Figure 34) provides options for developing and maintaining the form in Design View. (See Table 2 for a description of each button).

Figure 34 – Toolbox

Table 2 – Toolbox Button Description Tool Name Description

Label Used to insert text onto the form. Cannot be altered by the user.

Text Box Displays the values of a field from a table or query, or accepts input from the user.

Option Group Used to choose from a limited set of values.

Combo Box Used to enter a list of values or choose values from a list.

List Box Used to choose values from a list.

Image Used to display a static picture on a form.

Page Break Used to insert a page break.

Line Used to draw lines.

Rectangle Used to draw a rectangle.

Reports A report can be created based on either a table or query object(s). Reports provide a means to display and summarize the data in tables or queries. Reports can include headers and footers in which subtotals and totals can be calculated and displayed. The information from the tables

Introduction to Microsoft Access 2003 - 19

Page 20: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

and/or queries can also be arranged so that the report may be utilized as an invoice, order form, presentation, or for formatting and printing mailing labels.

Like other objects in Access, a report can be created in the Design View or with the Report Wizard. There are two basic formats for reports: columnar and tabular. The columnar report orients field names to the left and their values to the right as in a column form. The tabular report looks similar to the format of tables with the field names listed at the top and their values beneath the field names. Figure 35 is an example of a report in tabular format.

Figure 35 - Typical Database Report (Tabular)

CREATING A REPORT USING REPORT WIZARD A style of report can be created that is similar to one created in the Design View by using the Report Wizard. The wizard provides for selection of tables and fields. Additionally, field grouping, sorting, layout, and background styles provide a measure of control in the design of a report.

Figure 36 – New Report Dialog Box

To create a report using the Report Wizard: 1. Click the Reports button on the Objects bar in the Database window (see Figure 36). 2. Click the New button. The New Report dialog box opens (see Figure 36). 3. Select Report Wizard from the list box.

Introduction to Microsoft Access 2003 - 20

Page 21: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

4. Select “Contacts2” from the Choose the table or query where the object’s data comes from: drop-down list.

5. Click the OK button. The Report Wizard starts (see Figure 37). 6. Select a table or query to base the report on from the Table/Queries drop-down list. 7. Highlight the desired fields in the Available Fields: list box and move them to the

Selected Fields: list box using the single right-ward pointing arrow. 8. Click the Next> button.

Figure 37 – Report Wizard Dialog Box

9. Select a grouping level by selecting a field in the list box and clicking the right-pointing arrow button.

10. Click the Next> button (see Figure 38).

Figure 38 – Grouping Level Figure 39 – Field Sorting

11. Up to four selected fields can be sorted in either ascending or descending order by selecting the field from the drop-down list. Ascending button to the right of the drop-down list will change the sort order to Descending. Clicking the Descending button will change the sort order back to Ascending.

12. Click the Next button (see Figure 39). 13. Select a layout style by clicking on an option button in the Layout section. Select either

the Portrait or the Landscape option button in the Orientation section to orient how the report will print out on paper (a preview is displayed to the left).

14. Click the Next> button (see Figure 40).

Introduction to Microsoft Access 2003 - 21

Page 22: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

15. Select the style of the report from the What style would you like? list box (a preview shows in the left side).

16. Click the Next> button (see Figure 41).

Figure 40 – Report Layout Figure 41 – Layout Style

17. Enter “Contacts2” in the What title do you want for your report? text box. 18. Click the Finish button (see Figure 42).

Figure 42 - Report Title

Figure 43 provides examples of reports created using the Report Wizard.

Report Design View Report View

Introduction to Microsoft Access 2003 - 22 Figure 43 – Report created from the Report Wizard

Page 23: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

CREATING A REPORT USING DESIGN VIEW There are two ways to create a report: the Report Design window or the Report Wizard. Creating a report using the Report Design window requires skills for clicking, dragging, and aligning bound and unbound controls.

To create a report using the Report Design window: 1. Click the Reports button on the Objects bar in the Database window. 2. Click the New button. The New Report dialog box opens (see Figure 44). 3. Select “Design View” in the list box then select “Contacts2” from the Choose the table

or query where the object’s data comes from: drop down list. 4. Click the OK button. The Report Design window will open (see Figure 45).

Figure 44 – New Report Figure 45 – Report Design View

!NOTE: If the Toolbox toolbar does not open, click the Toolbox button on the toolbar or select the View menu, then select Toolbox.

5. Select the View menu then select Report Header/Footer . A Report Header section will appear on the report (see Figure 46).

6. Click the Label button on the Toolbox toolbar. 7. Draw a Label control in the Report Header grid. Start by pressing the left mouse button to

indicate the starting point then draw the Label while holding the left mouse button (see Figure 46 and Figure 47).

8. Release the mouse button when the Label has been drawn to the desired size. 9. Enter “ITS Contacts” in the label and press the [Enter] key.

Figure 46 – Insert Report Header and add a Label

Introduction to Microsoft Access 2003 - 23

Page 24: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

10. Select the label by clicking it. 11. Use the Formatting toolbar to change the presentation of the label text.

!NOTE: To enlarge the label click it and drag it to the desired size using one of the sizing handles. To enlarge the size of the Report Header, hover the mouse over the Page Header identifier and click and drag it when the cursor changes to an up and downward- pointing arrow .

12. Select “Title” from the “Contacts” field list box, drag it to the Detail section, and release the mouse button (see Figure 47).

Figure 47 – Adding Fields to the Report

13. Click either control to select it. Dragging a selection handle will resize the control. By positioning the cursor over the control so that the shape changes to an open hand and then dragging the control, you will see the unbound control and the bound control move together (see Figure 48).

!NOTE: Clicking either control and positioning the mouse so that the cursor shape changes to a forefinger pointing at the largest selection handle activates the independent movement selection handle (see Figure 49). This special selection handle allows one part of the control to be moved without changing the position of the other.

Figure 48 – Selecting Bound and Unbound Control

Figure 49 – Selecting Unbound Control

Figure 50 – Lining up Controls

14. Repeat steps 4 and 5 to add the following fields from the field list box: “Last Name,” “First Name,” “Address,” and “Phone Number.”

Introduction to Microsoft Access 2003 - 24

Page 25: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

15. Click each unbound control individually and change its format. Use the Formatting toolbar to change the Font Size, Style, Font Color, and Background Color of the bound controls. a. Click the Report Header identifier to change the background color. b. Select the Fill/Back color button on the Formatting toolbar. c. Select a color. d. If desired, repeat for the Detail section by clicking the Detail identifier .

Report Design Window Report View

Figure 51 – Report Design View and Report View

To save the report:-- Double check -- a. Click the Save button . b. Enter “Contacts” in the text box. c. Click the OK button.

It may be desirable to have a date and time stamp placed on the report so that the viewer will know when the report was generated. If the date and time stamp are included, the date and time are automatically placed on the report using the date and time settings of the computer.

To place a date and time stamp on the report: 1. Select the Insert menu. 2. Select Date and Time…. 3. Select the desired date and time style. 4. Click the OK button.

The date and time are inserted at the top left corner of the Report Header in the Report Design View. Click and drag the date and time to any location.

Creating a Page Header will cause the header information to be printed out on every page of the report.

To create a Page Header: 1. Click an unbound control so that the selection handles are visible. 2. Click the Cut button on the Report Design toolbar. 3. Click the Page Header section identifier (see Figure 50). 4. Click the Paste button on the toolbar. 5. The unbound control is placed in the Page Header section. 6. Drag the bound control to line it up under the unbound control (see Figure 50).

Introduction to Microsoft Access 2003 - 25

Page 26: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Printing Reports The report can be printed after it is created. The steps outlined below illustrate some of the options available when printing a report.

SELECTING PAGE SETUP OPTIONS You can specify the desired size of a printed report. In the Page Setup dialog box (shown in Figure 52) you can select a predetermined page size from the Size: drop-down list or you can manually enter the desired measurements. You can also select either the Portrait or Landscape option button in the Orientation section.

To adjust the Page Setup options: 1. Select the File menu. 2. Select the Page Setup… command. The Page Setup dialog box opens (see Figure 52). 3. Select the desired options by selecting the appropriate option buttons and/or selections in

the drop-down lists.

Figure 52 - Page Setup Dialog Box

PRINTING IN ACCESS Clicking the Print button on the Standard toolbar will automatically print one copy of your report on the default printer. Other options are available in the print set-up.

To preview a report before printing: 1. Click the Print Preview button on the Standard toolbar. 2. Click the document to view it in a magnified view. 3. To exit Print Preview, click the Close button on the Print Preview toolbar.

Introduction to Microsoft Access 2003 - 26

Page 27: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Figure 53 - Print Dialog Box

To print a selected range of pages from the report: 1. Select the File menu. 2. Select Print…. The Print dialog box opens (see Figure 53). 3. Click the Pages option button in the Print Range section. 4. Type in the page numbers you would like to print separated by commas and/or hyphens in

the From: and To: text boxes. As an example, “1-12,14,19” will result in the printing of pages 1 through 12, page 14, and page 19.

5. Click the OK button.

To print a selected portion of the records: 1. Select or highlight the records in the appropriate table in the database. 2. Select the File menu. 3. Select Print…. 4. Click the Selected Record(s) option button (see Figure 53). 5. Click the OK button.

To print multiple copies: 1. Select the File menu. 2. Select Print…. 3. Set the number of copies by clicking the In the Number of Copies: spin box in the Copies

section. 4. Click the OK button.

To select a printer: 1. Select the File menu. 2. Select Print…. 3. Select a printer from the Name drop-down list in the Printer section (see Figure 53). 4. Click the OK button.

Introduction to Microsoft Access 2003 - 27

Page 28: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Appendix: Setting Table Attributes

ASSIGNING DATA TYPES After naming a field, you must decide what type of data the field will hold. Before beginning to enter any data, you should determine the types of data that the database will use. See Table 3 for the basic data types.

Table 3 – Data Type Description Data Type Description Text A Text field is the default data type and can contain any

combination of letters, numbers, punctuation marks, and spaces. The default width is 50 characters and the maximum length is 255 characters.

Memo A Memo field is similar to a Text field, except that a Memo field can contain up to 65,535 characters.

Number A Number field can contain only numeric characters, a comma, a period, and a negative sign. Use a Number field when calculations will be performed on the data.

Date/Time A Date/Time field contains a date and/or a time, such as 7/22/99 or 17:34.

Currency A Currency field is similar to a Number field and can be used in calculations. However, the values in a Currency field can only have four decimal places, and they automatically appear with dollar signs ($) and thousands separators (,).

AutoNumber An AutoNumber data type means that Access automatically assigns a unique number (consecutively, starting from 1) to each record in the database. You cannot manually enter a value into the field or change the number once Access assigns it.

Yes/No A Yes/No field signifies one of two conditions, Yes or No. OLE object An OLE (Object Linking Embedding) object field connects a field

to other Windows applications. You use an OLE object data type for graphics, spreadsheets, or sound files.

Hyperlink A Hyperlink field stores a link to another location. The link could go to an Internet page, a Word document, an intranet, or even a form in the current database.

Lookup Wizard

A Lookup Wizard field contains a list of selected values from another table or a list of values you provide.

ADDING FIELD DESCRIPTION Comments are a useful means to indicate the purpose of the field or any special information that a user might need. Comments are entered in the “Description” column of the table design grid.

SETTING A PRIMARY KEY The Primary Key is a field or group of fields that uniquely identifies each record. The value of the primary key field(s) must not be found in more than one record.

The advantages of setting a primary key in a table include: The primary key makes information retrieval faster. When opening a table, the records are automatically sorted in order of the primary key. A primary key prevents entry of duplicate data.

Introduction to Microsoft Access 2003 - 28

Page 29: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Introduction to Microsoft Access 2003 - 29

USING FIELD PROPERTIES Each field has a set of properties that controls the way it stores, handles, and displays data. The field properties available in the Field Properties pane of the Design View window depend on the data type selected in the Design Grid pane. Some of the property types you can set (select) are listed in Table 4.

Table 4 – Field Properties Property type Description Field Size Limits a Text field to a specific number of characters or a

Number field to the range of numbers it can store. Format Controls the way data appears in Datasheet view. Decimal Places

Displays a set number of decimal places. This property type has no effect on Number data type using the General Number format and is available only for Number and Currency data types.

Input Mask Sets a pattern that determines the input format of data, such as the hyphens in a telephone number.

Caption Specifies a label other than the field name that appears in the table and on forms and reports.

Default Value Displays a specified value for a field in new records. Validation Rule

The value for the data entered must meet a certain requirement. For example, you can specify that the “Credit Limit” field cannot be greater than “$10,000.”

Validation Text

Specifies the text you want to appear in an error message if the data entered violates the validation rule.

Required Specifies that the field cannot be left empty when entering data into a record.

Allow Zero Length

Determines whether or not you can enter adjacent quotation marks (“ “) in a field to indicate that there is no data for that field in the record.

Indexed Speeds up retrieval of data in a field. All primary key fields are automatically indexed.

LIMITING FIELD SIZE You can only enter as much data into a field as is allowed by the field size. Further keystrokes are not permitted after typing the maximum number of characters allowed. You can only set the Field Size property for fields of data types Text, Number, and AutoNumber. All other field data types have default widths that are set automatically. The available field sizes are listed in Table 5.

Table 5 – Field Size Properties Field Size Size Range Decimal Places Byte 0 to 255 (no fractions) None. Data is

rounded. Integer -32768 to 32767 (no fractions) None. Data is

rounded. Long Integer -2,147,483,647 to 2,147,483,647 (no

fractions) None. Data is rounded.

Single -3.4x1038 to 3.4x1038 Up to seven. Double -1.797x10308 to 1.797x10308 Up to fifteen. Replication ID Globally unique identifier. Not available.

Page 30: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Introduction to Microsoft Access 2003 - 30

SETTING NUMBER FORMATS The Format property affects how data appears on the screen in Datasheet View - not how it is stored in the table or used in calculations. The available format for fields with Number data types are listed in Table 6.

Table 6 – Number Format Properties Format Description Example General Displays a number the way it was entered. This is the

default format. 3456.789

Currency Uses a comma as a thousands separator and displays a currency symbol. Negative numbers are displayed in parentheses. The default number of decimal places is 2.

$3,456.79

Fixed Displays at least one digit. The default number of decimal places is 2. The number in the field is rounded to the set number of decimal places.

3456.79

Standard Uses a comma as a thousands separator. The default number of decimal places is 2.

3,456.79

Percent Multiplies the number entered by 100 and places a percent symbol at the end. The default number of decimal places is 2.

99.80%

Scientific Expresses numbers as multiples of exponents of 10 in standard scientific notation.

3.46E+03

SETTING DATE/TIME FORMATS You can also change the format of a field with a Date/Time data type to change the way the date or time appears in a table. The available formats for fields that are Date/Time data types are listed in Table 7.

Table 7 – Date and Time Format Properties Format Description Example General Date

If the value is only a date, no time appears. If the value is only a time, no date appears.

7/4/99 or 6:30:15 PM

Long Date The day and month names are spelled out. Tuesday, July 4, 1999

Medium Date

The month name is abbreviated and the name of the day is omitted.

04-Jul-99

Short Date The date appears as numbers separately by slashes.

7/4/99

Long Time Times appear with hours, minutes, and seconds separated by colons and followed by an AM or PM indicator.

6:30:15 PM

Medium Time

This format is the same as the Long Time format except that no seconds appear.

06:15 PM

Short Time The time appears in the 24-hour clock format with no seconds.

18:30

SETTING YES/NO FORMATS Fields with Yes/No data types can display “yes” or “no,” “true” or “false,” or “on” or “off.” If you specify True/False as the format and a user enters “Yes,” Access automatically converts it to “True.”

Page 31: Introduction to Access 2003 425 course material/MS Acce… · STARTING MS ACCESS 2003 There are six Open Access Labs on campus. Access 2003 can be started from any of them. To open

Introduction to Microsoft Access 2003 - 31

SETTING DEFAULT VALUES You can set a default value for a field using the Default Value property. The default value is automatically entered in the field when you create a new record. To set a default value, enter an expression for the Default Value property. An expression consists of operators (i.e. =, +, -, *, /) and/or values. You can enter an expression directly into the Default Value text box, or you can use the Expression Builder.

SETTING VALIDATION RULES AND TEXT Validation rules for a field are set using the Validation Rule property. Access checks the validation rule when you enter data into a field of a new record. If the value you enter does not meet the conditions of the validation rule, Access displays a Warning box to indicate the error. You can specify the text you want to appear in the Warning box message using the Validation Text property. Table 8 lists examples of validation rules and text.

Table 8 – Validation Rule Properties Symbol Example Description = = 10 Value must equal to 10. >, < >10, <10 Greater than 10 or less than 10. >=, <= >=10, <=10 Values must be greater than or equal to 10, less

than or equal to 10. <> <>100 Value must not be equal to 100. # #01/01/2002# Marks the start and end of date values in rules. Like Like “Smith” Value must be “Smith”. And >10 AND <20 Value must be greater than 10 and less than 20. Not Not “Department” Value must not be “Department”. * Like A* Value must begin with “A.” ? Like Fre??it Value must begin with “Fre,” end with “it,” and

have two characters in the middle.