Microsoft Access XP Basic

4 downloads 160 Views 434KB Size Report
Basic. Access XP is an electronic relational database-management system. .... Below are listed the different objects that Microsoft Access XP database can be ...
Microsoft Access XP Basic

Table of Contents: DATABASE TERMINOLOGY:

5

THE ACCESS ENVIRONMENT:

6

ACCESS XP BARS: THE TASK PANE (OR COMMON TASK PANE): OPENING A DATABASE: TO OPEN A DATABASE USING THE MENU BAR:

7 7 8 8

THE DATABASE WINDOW:

8

CREATING A NEW DATABASE: TO CREATE A NEW BLANK DATABASE (WITHOUT USING DATABASE WIZARD): DATABASE WIZARD: TO CREATE A DATABASE USING THE DATABASE WIZARD:

10 10 10 10

TABLES:

11

OPENING A TABLE: TO OPEN A TABLE OBJECT BY DOUBLE-CLICKING: CLOSING A TABLE: TO CLOSE A TABLE BY USING THE CLOSE BUTTON: KEEP IN MIND: RELATIONSHIPS: WHEN RELATING TABLES TOGETHER: TYPE OF RELATIONSHIPS: PRIMARY KEYS: THREE TYPES OF PRIMARY KEYS: TABLE NAVIGATION: TO MOVE AROUND WITHIN A TABLE CHANGING VIEWS: TO VIEW A TABLE IN TABLE DESIGN VIEW: CREATING A NEW TABLE: TO CREATE IN DESIGN VIEW: TABLE WIZARD: TO USE THE TABLE WIZARD: TO CHANGE FIELD NAMES: TO INSERT FIELDS: TO DELETE FIELDS: FIELD ORDER: TO REARRANGE FIELD ORDER:

12 12 12 12 13 13 13 13 14 14 14 14 15 15 16 16 16 16 17 17 17 18 18

Page 2 of 37

NUMBER FIELD PROPERTIES: ADDING RECORDS TO A TABLE: FINDING RECORDS: TO FIND CERTAIN VALUES WITHIN FIELDS: TO FIND RECORDS NO MATTER WHICH FIELD YOU ARE IN: DELETING RECORDS: TO DELETE A RECORD: YOU CAN ALSO DELETE A RECORD BY: FILTERING AND SORTING RECORDS: TO FILTER: TO SORT: TO SORT BY MORE THAN ONE FIELD:

18 18 19 19 19 20 20 20 20 20 20 21

QUERIES:

21

SELECT QUERIES ARE MADE UP OF THREE COMPONENTS: CREATING A QUERY: TO CREATE A QUERY IN DESIGN VIEW: TO CREATE A QUERY FROM AN OPEN TABLE: SELECTING FIELDS: TO RUN THE QUERY: ESTABLISHING CRITERIA: USING OPERATORS: USING CALCULATIONS IN QUERIES: TO CALCULATE IN A QUERY: CALCULATING USING THE TOTAL ROW: TO CALCULATE USING THE TOTAL ROW: JOINING TABLES IN A QUERY: TO JOIN MANUALLY: JOINING TABLES PERMANENTLY: TO JOIN TABLES PERMANENTLY:

21 22 22 22 23 23 23 23 24 24 25 25 25 25 26 26

FORMS:

27

TO CREATE A FORM WITH THE FORM WIZARD: TO CREATE A FORM WITH AN AUTOFORM: NAVIGATING IN FORMS: TO NAVIGATE IN A FORM: TO ENTER DATA INTO A FORM: USING DESIGN VIEW: MOVING CONTROLS: TO MOVE JUST THE LABEL: TO MOVE JUST THE TEXT BOX: TO MOVE BOTH TOGETHER: TO MOVE MULTIPLE CONTROLS: TO SIZE CONTROLS: CONTROL PROPERTIES: TO VIEW PROPERTIES: TO ADD A TITLE TO A FORM:

27 27 27 27 28 28 29 29 29 29 29 29 30 30 30

Page 3 of 37

MULTIPLE TABLE FORMS:

31

REPORTS:

31

TO USE THE WIZARD TO BUILD A REPORT: GROUPING: TO CREATE GROUPS IN A REPORT IN DESIGN VIEW: LAYOUTS & STYLES: TO CHANGE STYLES: REPORT SECTIONS: TO CREATE A REPORT FROM A QUERY: TO APPLY AN AUTOFORMAT: PRINTING THE REPORT: TO PRINT A REPORT BY USING THE MENU BAR:

31 32 32 32 33 33 34 34 34 34

IMPORTING AND EXPORTING:

35

TO IMPORT DATABASE OBJECTS FROM OTHER ACCESS DATABASES: TO IMPORT MULTIPLE OBJECTS: TO IMPORT EXCEL FILES INTO AN ACCESS DATABASE: TO EXPORT TABLES AS EXCEL FILES: TO LINK TABLES: TO USE THE LINK TABLE MANAGER: COMPACTING DATABASES: TO COMPACT A DATABASE:

35 35 35 36 36 36 37 37

Page 4 of 37

Access 2002 (XP) Basic Access XP is an electronic relational database-management system. A database is a collection of related information. Access XP allows you to manipulate this collection of related information by storing, organizing, sorting, extracting, filtering, summarizing, printing, etc. easily and efficiently. Common examples of databases would include telephone lists, student rosters, employee work schedules, inventory control records, medical records, personnel records, class attendance records, etc. Nearly any information that is related in some way can be put together into a database.

Database Terminology: Database

a collection of information that is related by particular topic or purpose and the tools for manipulating that information. You can think of a database file as a container (or box) that holds all parts of a project.

Table

a collection of records or a collection of information presented and stored in a row and column format, similar to a spreadsheet program. Tables are the foundation of all other objects in a database. Since Access is a relational database, you can have separate tables containing separate information, but be able to pull needed related data into one table.

Field

a column in a table that contains one category of information. For example, name, phone, date hired, etc.

Record

a combination of fields that make up one row in the database. For example, a name, address and phone field could make up a record for an individual.

Data Value

one item of data. The content of any field, for example, the “last name” of someone.

Page 5 of 37

The Access Environment: Title bar

Menu bar

Standard toolbar Task pane

N

aming Conventions:

When you start to create databases you need to make sure you are naming them in a logical and consistent manner. Naming conventions are not necessary, but they make your work consistent and easy to share among other database programs. Naming conventions can be the use of “tags” that preface or follow the name of an Object. For example, tblTableName . You can choose to follow an established naming convention or make up your own. No matter what you chose to do, name your Objects in a logical and descriptive manner.

R

ules for Database Design:

Status bar

Each database is set up for a specific purpose. What you include and how you set up the database will dictate on what you can have the database do for you. You want to make sure you design the database so that you and others can easily accomplish what you need it to do.

Page 6 of 37

Access XP Bars: Component

The Menu bar

The Title bar

The Standard Toolbar

The Task Pane (or Common Task Pane) The Status bar

Description The menu bar shows all the menus available in Access XP. A menu contains the commands to perform a set of related tasks. For example, the File menu contains commands to perform file management tasks such as opening, saving, printing, etc. The Title bar contains buttons that you can use to change the window size or close the window. The Access XP Program Title bar displays the program name. The Database Title bar displays the name of the database file and the object currently selected. The Standard Toolbar contains buttons for frequently used actions, such as opening or saving a file. The buttons are shortcuts to some of the commands available in the menus. The Task Pane contains shortcuts to frequently performed tasks such as creating a new database, copying and pasting and seaching. The Status bar displays the current status of any ongoing tasks at the bottom of the screen.

The Task Pane (or Common Task Pane): The Task Pane is new to Access XP. When first opening Access XP, the New File task pane makes it easier to create new databases or open existing databases. The Task Pane will change depending on what procedure you are completing, such as Copying or Searching. Once you’ve accessed an item from the Task pane, the Task pane will disappear. However, you can always turn on the Task pane again at any time by choosing View, Toolbars, Task Pane from the Menu bar.

Page 7 of 37

Opening a Database: You can open a database in several ways, such as: 9 Choose File, Open from Menu bar. 9 Click on the database you wish to open from the Task pane. 9 Click Open button from Database Toolbar.

To open a Database using the Menu bar: 1. 2. 3. 4.

Choose File, Open from Menu bar. Navigate to the folder which contains the Database file. Select the database file you wish to open. Click Open button.

The Database Window: Toolbar

Object bar

The Database window will have the name of the Database displayed in the Title bar along with the format of the database file.

Page 8 of 37

By default, Access XP creates databases using the Access 2000 file format. Therefore, a database you create in Access 2000 can be easily opened in Access XP and vice-versa. The Database window also contains its own Toolbar from which you can choose short cuts to manipulate the Database window environment or objects. The Objects bar will contain a list of section from which you can open already created objects or create new ones. Objects are components that make up a database. Each database can be a combination of different sets of objects. Below are listed the different objects that Microsoft Access XP database can be composed of: 1. 2. 3. 4. 5. 6. 7.

Tables Queries Forms Reports Data Access Pages Macros Modules

These objects are beyond the scope of this class.

Table

used to store and present a collection of information in a row and column format. Tables should always be created first. They are the foundations upon which all other objects are based.

Form

an object used for entering and viewing information stored in a Table and/or displayed in Query. A form gets its data from the Table or Query that it is based upon.

Query

enables you to ask questions of, search for, analyze and select certain information that is stored within a Table and/or other Query.

Report

enables you to print information resulting from a Table and/or the results of a Query a designated format. Foundation Objects

Tables Basis for other objects

Forms

Queries

Page 9 of 37

Reports

Creating a new database: You can create a new database by either using the Database Wizard or creating a new blank database yourself. You can name your database nearly anything you want, however there are some rules that should be followed: Database names cannot – 9 have more than 64 characters. 9 start with a space 9 include a period (.), exclamation mark (!), accent grave (`) or brackets ( [] ) Creating a database file by hand (without the help of the Database Wizard) gives you more creative flexibility as you are responsible for name and designing all the objects in the database.

To create a new blank database (without using Database Wizard): 1.

Click Blank Database from Task pane on right side of screen. If Task pane is not displayed, click the New button on Standard toolbar or choose File, New from Menu bar to display Task pane.

2. Choose Blank Database from Task pane. 3. Name the new database file. 4. Click Create button.

Database Wizard: The Database Wizard is a little program that will help you create your database by asking you a series of questions and offering a series of choices in order to quickly get your database created. Depending on the choices your make when using the Database Wizard will dictate the type of Database that will be created.

To create a database using the Database Wizard: 1. Choose New from Template from the Task pane on right side of screen. If Task pane is not displayed, click the New button on Standard toolbar or choose File, New from Menu bar to display Task pane.

Page 10 of 37

2. 3. 4. 5. 6. 7. 8.

Click the Databases Tab. Click the desired database template. Click OK. Name the new database. Click Create button. Follow all the steps and answer all the questions posed to you by the Wizard. Click Finish button when done.

Typically the Database Wizard will contain more advanced features than if you were creating the database by hand. However, using the Database Wizard is a good way to explore more advanced objects and learn new design techniques.

Tables: Columns

Rows

A table is an Object in your database. You can have multiple Tables in your database. Tables are the “foundation” objects of all other Objects in the database. The Table contains the “data” for which you are creating the database. Tables are made up of rows, columns and data values. Columns are referred to as fields and contain categories of information. Rows are referred to as records and contain all the categorical information for one entry in the database, such as customer or product information. Tables, as all other objects, have at least two sides or views. When you first open Table you are looking at the actual data contained in the Table or datasheet view. If you’d like to see or manipulate how the Table is designed, you would move to Design view.

Page 11 of 37

Opening a Table: There are various ways of opening Tables in Access XP. You can open a Table object by double-clicking on the Table name; by selecting the Table, then choosing the Open button on the Database Toolbar; or by right-clicking on Table and choosing open from the Short Cut menu.

To open a Table object by double-clicking: 1. Click on Tables Section in the Objects Toolbar. 2. Double-click on name of Table you wish to open.

Closing a Table: There are various ways to close a Table in Access XP. You can close a Table by choosing File, Close from Menu bar; clicking the X button in the upper, right corner of Database window (not the Access window); by clicking the Menu Object Icon in upper, left corner of Database Toolbar and choosing Close; or right clicking on Table button in the Task bar at very bottom of Windows screen and choosing Close.

To close a Table by using the Close button: 1. Click the X in the upper, right corner of Database window. Be careful when closing objects using the Close button. Make sure you are choosing the X that belongs to the Object, not the Application. If the object is NOT maximized, the close button will be a big, red X. If the object is maximized, the Close button will be a small, black X that is directly underneath the Access Application Close button (which will look like a big, red X).

Tables should be “normalized” as much as possible to insure data integrity. Tables should be created before any other Objects are created, however, you can create a Form early on designed to input data into the Table. Make a conscious effort to protect your Tables. All other Objects can be re-created if need be, but having to re-create a Table could be very difficult, if not impossible.

Page 12 of 37

Keep in Mind: 1. Each field in a Table should contain the smallest meaningful value possible. Don’t combine two data values within one field. For example, don’t include first and last name within the same field. It will be hard to sort by first or last name individually if you do this. 2. Each Table should focus on one topic at a time and should only store information related to that topic. When first putting together tables, the urge is to put as much information within one table as possible, even if the fields are not related. This causes huge tables that are hard to manipulate later on. It also encourages redundant and duplicated information. Although these rules may sound logical, it can be easy to overlook them. The above 2 rules, if followed, will satisfy the first level of Normalization. Normalization is a 3 to 5 step process of insuring data integrity by following explicit rules of normalizing.

Relationships: Access 2000 is a relational database-management system; therefore, you can view information from other tables by joining, or relating, them to one another.

When relating tables together: 1. You always work with two tables at a time. 2. To join two tables, there must be a “field” that is common to both of them. 3. The common fields must contain identical information for each record.

Type of Relationships: 1. One to One: when each record of the first table matches only one record in the second table. 2. One to Many: when each record of the first table matches more than one record in the second table. 3. Many to Many: when each record in the first table matches multiple records in the second table and multiple records in the second table match multiple records in the first table.

Page 13 of 37

Primary Keys: A primary key is a field or combination of fields used to identify each record in a table. They aren’t mandatory, but they are highly recommended because they allow Access to relate data quickly among different tables. Primary Keys are also automatically indexed, which speeds the lookup of records in a table. Access automatically sorts the records in a table by the Primary Key. You cannot have duplicate information in the Primary Key field or leave that field blank.

Three types of Primary Keys: 1. Auto-Number 2. Single-Field 3. Multiple-Field

used to automatically enter a sequential number when a record is added to the table. commonly used for fields that contain unique values, such as social security number, employee numbers, part numbers, etc. used in situation where one field in not unique, but two fields used together contain unique values.

Primary Keys are used to identify the records within a table. A Primary Key cannot be left empty. Primary Keys should use fields that contain short values, rather than multiple words or real long data values. A Primary Key field must contain unique information and cannot be duplicated.

Table Navigation: There are many ways that you can move around with a Table in Datasheet view. Being able to get to different parts of the Table is necessary in order to add or edit data values of a particular record or to search for record information.

To move around within a table 1. 2. 3. 4. 5. 6. 7. 8. 9.

Use arrow keys. Use Tab key to move a field to the right. Shift+Tab to move a field to the left. Use End key to move to the last cell in the current row. Use Home key to move to the first cell in the current row. Control+Home to move to the first cell in the table. Control+End to move to the last cell in the table. Use Scroll Bars to move up or down, left or right. Click on Record button to move through the list of records in the table.

Page 14 of 37

Changing Views: As mentioned earlier, every object in a Database has at least two different views; the open view and the design view. In Tables and Queries the open view is referred to as the Datasheet view because you can see the data. Access XP has added two new view options, Pivot Table and Pivot Chart views, for use with Table and Forms. Pivot Table view helps you to analyze data, while Pivot Chart view help you display data graphically in either Datasheet or Form view. However, using these views will not be discussed in this handout as it is beyond the scope of the class.

To view a table in Table Design View: 1. Click on the View Button on the Standard Toolbar to change views. 2. The table is displayed in a window with two panes: Field List Pane & Field Properties Pane. 3. F6 – moves between the two panes. 4. The top pane is where you create, edit and delete field names and data types. 5. The bottom pane is where you include the properties to define the characteristics of each field. Each field will have a “data type” associated with it. The data type helps you decide what type of information you need for a particular field.

Page 15 of 37

Text .......................................text and numbers on which no calculations will be made. Number .................................numerical data on which you can perform calculations (excludes money). Currency ..............................values which represent money. Date/Time..............................date and time. Yes/No ..................................fields that can contain one of two values (yes/no, true/false, on/off, etc). Memo ....................................lengthy text and numbers used to give information. AutoNumber ........................sequential numbers inserted by Access. OLE Object ..........................object linking and embedding created in another application.

Creating a new Table: You can create a new table in Access XP in many different ways. Tables can be created in Design view or by using the Table Wizard. Tables can also be imported or linked into the database from outside sources.

To create in Design view: 1. 2. 3. 4. 5.

Open the database to which you want to add a new table. Make sure you are in the Tables section of the Object bar. Double click Create Table in Design View option. Add field names, field data types and any decriptions for each field in your Table. Add any additional properties to each field from the Properties Pane at bottom of screen. 6. Save and name the Table, if necessary. 7. Move to Datasheet view to add the data.

Table Wizard: The Table Wizard will assist you in making a table by offering sample tables from which you can pick. Each sample table is already set up with the proper fields that you’ll need. You simply choose the fields you want to include into your table. Once you’ve told the wizard everything you want to include, Access will build the table for you. You can always edit the fields even after the Table Wizard has already built the table.

To use the Table Wizard: 1. Choose the New Database button from the Tables Tab. 2. Choose Table Wizard. 3. Click OK.

Page 16 of 37

4. 5. 6. 7. 8. 9.

Choose the type of table you want to create. Select the fields you want to include in your table. Move them to the Fields in my new table: box. Click Next to go on the next part of using the Wizard. Name the table (remember to use proper LNC naming conventions) Answer the questions that the Wizard asks of you, when done click on Finish.

Although the Table Wizard is good for helping you create a table, you still may need to modify the table.

To change Field Names: 1. Switch to Design Table View. 2. In the proper field, change the name as needed. 3. Click on Save button once changes have been made.

To insert fields: 1. 2.

Move to Design View. Click on the row selector button to select the row below where you want the new field to be inserted. 3. Click on Insert Rows button from Toolbar in Design Table View. 4. Rows automatically come in above the row you had selected.

To delete fields: 1. Click on the row selector button to select the whole row. (Drag pointer on row selectors to select multiple rows.) 2. Click on Delete Rows button from Toolbar in Design Table View. *Although it is not necessary to be in Design View to insert or delete fields, it gives you the most control over creating the fields.

Page 17 of 37

Field order: Once you’ve created all the fields for your table, you may decide that you would like to rearrange the order of the fields. By default, the order in which you create the fields will be the order in which they display in datasheet view, however they can easily be rearranged into a new order.

To rearrange field order: 1. 2. 3. 4. 5.

Move into Design view. Select the field you wish to move. Click and hold on select arrow on far left of field name. Drag to new location in field list. Release mouse.

You can also cut and paste to rearrange fields.

Number Field Properties: When deciding what type of property a number field should have, keep in the mind the following: 1. Integer and Long Integer settings do not include decimals. 2. Single can display up to seven decimal places. 3. Double can display up to fifteen decimal places.

Adding Records to a Table: Once you’ve designed your table, you are ready to input data (or records) into it. Records are typically typed in by hand, but also can be pasted from other tables or imported from outside sources. 1. Click in the first cell of the first blank record (or choose New Record button from Standard Toolbar or the Record Chooser area at bottom of screen). 2. Type the proper information in the proper fields. 3. Press Tab, Enter, arrow keys or click to move to next field.

Page 18 of 37

Pressing Control + ‘ (apostrophe) within a field will insert the same value from the above field. Pressing Control + ; (semi-colon) will insert the current date into a field of a record.

When you move from row to row, the last record you moved from automatically saves itself. You can also save data by choosing Record, Save Record from Menu bar. Clicking the Save button on the Standard Toolbar will not save a record. You cannot insert a new record in the middle of other records. You can only add new records at the bottom of the table. Records are inputted in data entry order. You can sort the table later to put into a certain alphabetical or numerical order.

Finding Records: You can locate certain fields within the table or you can just search for certain records no matter the field.

To find certain values within fields: 1. 2. 3. 4.

Place cursor within the field through which you want to search. Click on Find button from Tool bar. Specify what you want to find. Click on Find First, to find the first item in the table. (Choose Find Next, to find the next item depending on where the cursor is currently sitting).

To find records no matter which field you are in: 1. 2. 3. 4. 5.

Click on find button on Toolbar. Specify what item you want to find. Uncheck the Search Only Current Field check box. Click on Find First to find first item in the Table. Click on Close to close the find box.

Page 19 of 37

Deleting Records: Once you’ve added records, there may be times where you need to some them from the table as they are no longer valid. For example, if an employee leaves the company, you no longer need to keep that employee’s information in this table. WARNING! Deletions are permanent and can not be undone. Be very careful when you delete a record as you will not be able to un-delete. If you accidentally delete the wrong record, you will have to re-input the missing data.

To delete a record: 1. Place the cursor within the record you want to delete. 2. Choose Delete Record button from Toolbar.

You can also delete a record by: 1. Selecting the record, then pressing Delete on keyboard. 2. Right-clicking on Record Selection arrow, then choosing Delete Record from Short cut menu. 3. Choosing Edit, Delete Record from Menu bar.

Filtering and Sorting Records: There will be times when you only want to see certain records out of the whole table. To display only these certain records you can filter them out.

To filter: 1. 2. 3. 4. 5.

Start at the top of the table. Place cursor within the cell that contains the data you want to filter for. Click on Filter by Selection button from Toolbar. Observe the Table – only the filtered data should be displayed. To remove the filter, click on the Remove Filter button from Toolbar.

To Sort: 1. 2. 3. 4.

Put mouse pointer anywhere in the field that you want to sort by. Click on either Sort Ascending or Sort Descending buttons from Toolbar. Observe the table – the records should be displayed in the proper order. To remove the sort, choose Records, Remove Filter/Sort from Menu bar.

Page 20 of 37

To Sort by more than one field: 1. 2. 3. 4. 5. 6. 7. 8. 9.

Choose Records, Filter, Advanced Filter/Sort... from Menu bar. Click on Clear Grid button, if there are any values in any of the fields. Find the field that you want to sort by first from the list of fields displayed. Click and hold on the field and drag it to the first open field slot on the grid at the bottom of the window. Find the next field you want to sort by. Drag to the second open field slot. Once you’ve got the Sort filter set up the way you want, click on the Apply Filter button from Toolbar. Observe the records for accuracy. To put the records back into their original order, choose Records, Remove Filter/Sort from Menu bar.

There is no Remove Sort button available on the Toolbar.

Queries: Select Queries are objects that are used to locate only certain records from a table, multiple tables or other Queries. There are different types of Queries. Queries can allow you to update, append or delete records from tables besides finding only certain records. The Queries that allow you to find only certain records are called Select Queries.

Select Queries are made up of three components: 1. the source of the data (i.e. a table) 2. the question (what you want the query to find) 3. the answer (what the query came up with). Query results display themselves in a temporary datasheet called the Query Datasheet (or Query Result Set) view. However, you can decide to save the Query as an object to be used at a later time. For example, if you design a Query to find all the employees that have worked at the company 20 years or longer – you can save that Query and use it every year to locate new employees that have crossed that threshold. The Query result is always current information as it is based upon the current data in the underlying Table or Query. Queries can be based on only one underlying Table or Query, or multiple Tables or Queries. In order to base a Query on more than one Table/Query, the underlying objects must be related.

Page 21 of 37

Creating Multiple Table Queries won’t be discussed in much detail in this handout as it is beyond the scope of this class.

Creating a Query: You can create a Query in two different ways. You can first open the object that you want to base the Query on, then design the Query OR you can design the Query based on an object that you choose. You can also use the Query Wizard to help build a Query.

To create a Query in Design View: 1. 2. 3. 4. 5. 6. 7.

Move to the Query section in the Objects bar. Double click on Create Query in Design View. Add the needed Tables to the Field List Pane. Close the Show Table window. Add the needed fields to the Query Design Grid. Run the Query. Save the Query.

To create a Query from an open Table: 1. 2. 3. 4. 5. 6. 7. 8.

Open the table you want to base the Query upon. Click on the New Object button on Toolbar. Choose Query from drop-down list. Choose Design View. Click OK. Add the needed fields to the Query Design Grid Run the Query. Save the Query.

Page 22 of 37

Selecting Fields: You can drag fields from the field list in upper pane to the proper area on the design grid or you can click within the field section on the design grid and choose the desired field from there. The order in which you set up the query will be the order in which you see the results of the Query.

To run the Query: 1. Click on the Run button (!) from the Toolbar.

Establishing Criteria: If you put in criteria for the query in the Criteria section on the design grid, the query will only look for that criterion when running. This limits the result of the query to display only specifically desired records.

Using Operators: Operators are used to define a range of values for the criteria. Wildcards, And, Or, Greater Than and Lesser Than are commonly used operators. Comparison Operators < > = =

Meaning less than greater than equal to less than or equal to greater than or equal to not equal to

And Conditions:

is when two or more criteria must all be true for the records to be included in the result. And conditions can be used across multiple fields or And conditions can be used within one field when establishing ranges of criteria.

Or Conditions:

is when two or more criteria are present of which at least one must be true to be included in the result. The Or row is directly beneath the criteria row in the design grid. You can use Or conditions in more than one field or within one field.

Null Values:

some records may not have values in certain fields, but they should have. To search for records with null values, you can use the phrase “is null” in the criteria row of whatever field you are looking for.

Page 23 of 37

Only the records that have no values in those fields will be displayed. Wildcards:

common Access operator that you can use as a placeholder. Two frequently used wildcards are the question mark (?) and the asterisk (*). The question mark is used to substitute for a single character and the asterisk is used to substitute for any number of characters.

Once you’ve queried a table, you can make changes to the query and the changes affect the underlaying table. For example, if you queried for people who haven’t paid their parking fees, you can then enter the parking fee information directly into the Query and the changes will affect the table that the Query was based on.

Using Calculations in Queries: If your table includes fields that can be calculated together to produce a result, there is no need to include a field for the result in the actual table. For example, if you want to know what the retail price of an item was and you already had fields for sub-total and tax, all you have to do is calculate those two fields and produce the desired result in a Query..

To calculate in a Query: 1. In the design grid of a Query, click in the next field cell that isn’t in use. 2. Type the names of the fields that you want to calculate within square brackets []. 3. Type the operator that you want to use to perform the calculation. (for example, * for multiplication). 4. Type the other field names within brackets. 5. The calculation is called an Expression and you’ll see the name of the new calculated field start off with Expr1: (However, you should change that name to something more descriptive). 6. Run the Query.

Page 24 of 37

Calculating using the Total Row: There will be times where you’d like to perform calculations on “groups” of records, instead on individual records. To calculate values for a group of records, you can use aggregate functions by adding the values to the Total Row of the Query Design grid.

To calculate using the Total Row: 1. In the Query Design grid, pull down the desired fields you wish to use in the total. (Typically, you will only have two fields; the one you wish to group by and the one you wish to total). 2. Click the Totals button on Standard Toolbar. 3. In the Totals row of the Query Design Grid, select the type of calculation (i.e. sum, max, avg, etc.) you wish to perform for the field you wish to calculate.

Joining Tables in a Query: Pulling data from more than one table enables you to get the most out of your database. Whenever you construct a query involving two or more tables, you must tell Access how to hook (or link) the information within the tables together. You can permanently relate Tables in the Relationship window found from the Database window or you can relate Tables specifically for use in a Query. Access will automatically join two tables in a Query if they each contain a field with the same name and data type with at least one field being the primary key. Otherwise, you’ll have to manually join the tables.

To join manually: 1. 2. 3. 4.

Make sure you are in the Query design window. Click on the Show Table button from the toolbar. Add the table you want to join with the other table. Click and hold on the field of one table and drag to the common field in the other table. 5. You’ll see a line joining the two tables together.

Page 25 of 37

Joining Tables Permanently: Joining Tables permanently will establish the relationship between Tables unless specifically deleted. Tables that are joined permanently don’t have to be joined again when creating Queries – the relationship automatically appears in the Query Design view. If you already have a Query created with a relationship established when you create a permanent relationship between the same Tables – the permanent relationship will replace the temporary relationship from the Query Design screen, if applicable.

To Join Tables Permanently: 1. Move to the Database window. 2. Click on the Relationship button from Standard Toolbar. 3. Click the Show Tables button from the Relationship window toolbar. 4. Add the necessary Tables to the Relationship window. 5. Close the Show Tables window. 6. Find the common field between two Tables. 7. Drag the common field from one Table to the common field in the other Table. 8. Enforce Referential Integrity, if desired. 9. Click Create button. 10. Close the Relationship window. 11. Choose Yes if asked to save the layout. The purpose of joining tables whether temporarily or permanently is for the purpose of creating Queries based on more than one table. Although the ability to create multipletable queries is a key feature of Access XP, this skill is beyond the scope of this class and won’t be discussed in any depth.

Page 26 of 37

Forms: Forms are used to customize the display of data in a Table or Query. You can use Forms to input information into Tables or simply view the information from a Table or Query. When creating a Form, you can decide how you want to the form to look and where to place the controls. You can use formatting options to make the form very eye appealing. Although you can create a Form in Design view – it’s usually much quickly and easier to create Forms with the Form Wizard or use AutoForms

To create a Form with the Form Wizard: 1. 2. 3. 4. 5.

Move to the Forms section in the Objects bar. Double click on Create form using wizard. Choose the Table/Query you want to base the Form upon. Select the fields that you want to include within the Form. Continue to click Next and follow the directions of the Wizard until the form is complete. 6. Click on Finish.

To create a Form with an AutoForm: 1. 2. 3. 4. 5. 6.

Move to the Forms section in the Objects bar. Choose New from the Database Toolbar. Choose the desired AutoForm from the list. Select the object upon which you are creating the Form. Click OK. New form should appear on screen within a few seconds.

Navigating in Forms: You can navigate within the Form just as if you would within the Table by using the navigation buttons in the bottom, left corner of the screen. You can also enter new records within the form that will be added to the underlying table.

To Navigate in a Form: 1. 2. 3. 4. 5.

Use arrow keys. Use Tab key to move a field to the right or down. Shift+Tab to move a field to the left or up. Press Home to move to the first field of the current record in the form. Press End to move to the last field of the current record in the form. Page 27 of 37

6. Control+Home to move to the first field of the first record in the form. 7. Control+End to move to the last field of the last record in the form. 8. Use Navigation area on bottom, left corner of screen.

To enter data into a Form: 1. Click New Record button, if necessary. 2. Type in desired data into each field. 3. Make sure you move the focus off of the last record to save it.

Using Design View:

Label Controls

Text Box Controls

Field List

Toolbox

Changes to the design of a Form must be done within the Design view. Each area of the form is called a “control”. The label controls are the items that correspond to the caption properties in the Table design view. The field names are included in text box controls. The text box controls get the information from the fields in the underlying table.

Page 28 of 37

Controls can be bound or unbound. Bound controls refer to controls that are getting their information from the underlying table. Those controls are “bound” to the table. Unbound controls are not linked to any fields in the table.

Moving Controls: You must select the controls you want to move. By clicking on either a label or text box, automatically the other control item is also activated. However, you can choose to move just the label, just the text box or both together.

To move just the label: 1. Click on the label control. 2. Point to the upper, left corner of the control until the pointer changes to a pointing finger. 3. Click and hold with the pointing finger pointer and drag control to new location.

To move just the text box: 1. Do same as with label, except click on the text box first.

To move both together: 1. Click on either label or text box. 2. Point to the line between the sizing handles on the active control until the pointer changes to an open hand. 3. Click and hold with open hand and drag both controls to new location.

To move multiple controls: 1. 2. 3. 4.

Click on one control. Hold down the Shift key and click on the next. Continue clicking on the controls you want to activate with the Shift key held down. Once you’ve got all the needed controls selected, use the open hand to move the controls to the desired location.

To size controls: 1. Click on the control you want to size. 2. Click and hold on one of the sizing handles (little boxes that appear around the active control). 3. Drag to change the shape of the control.

Page 29 of 37

To make the contents of the control fit within the size of the control, you can choose Format, Size, To Fit from Menu bar.

Control Properties: Each control displayed in your Form has it’s own set of properties that decide it’s general appearance and behavior.

To view properties: 1. 2. 3. 4. 5. 6.

Select the control you want to see the properties on. Right click on control & choose Properties. Click on the All tab to see all the properties. Scroll to desired property. Change any, if needed. Close properties box.

Adding a Title to a Form: It’s suggested that you add a Title to all Forms to make the purpose of the Form clear. If using a Form Wizard a Title will be added for you. If creating a Form in Design view, you will need to add the Title.

To Add a Title to a Form: 1. Make sure there is enough room in the Form Header section to add text. (if you can’t see the Form Header area – choose View, Form Header/Footer from Menu bar). 2. Display the Form Toolbox toolbar. 3. Click on the Label tool. 4. Click within the Form Header. 5. Type the title. 6. Format as needed. Once you’ve gotten your form designed, you can look at it whenever you want by clicking on the Form view button on Standard Toolbar. Once you’ve looked at it, you can go back into Design View to make additional changes. You can find, sort and filter within a form just as you would within a table.

Page 30 of 37

Multiple table forms: You can base a form on a query if you want to join tables, sort records or select records automatically when the form is opened. You cannot determine which object a form is based upon by viewing it in Form view. However, you can tell whether the form is based on a table or query by checking the Record Source Property. If the form is based on a multiple table query, it most likely displays only some of the fields from each Table. Therefore, you can view and change data by using the form, but you may want to avoid adding new records by using this type of Form. If all the fields from the source Tables are not displayed in the Form, then you do not have access to everything, so some information will be left out. You can always go back to the original Table and add the information back in, but this can take some time. Also, when you are basing a form on a multiple table Query, you should use caution when editing the values in the form. For example, if you change a certain value for one employee such as the parking lot fee - that change could be recorded into the Parking Lot source table and would actually change the data for everyone assigned to that parking lot.

Reports: You can print individual datasheets and forms, but using a report to print data usually makes your information more presentable and meaningful. You can decide what fields you want to use in the report and group and/or sort the records. You can also summarize calculations in your reports. Using the Report Wizard is the easiest and most efficient way of creating a basic Report. It prompts you with questions and uses your responses to quickly create a Report based on a Table or Query that you designate. However, even after the Report Wizard builds your report, you may want make slight changes if needed.

To use the Wizard to build a report: 1. 2. 3. 4. 5. 6. 7.

Click on the Reports tab. Click on New. Click on Report Wizard. Select the table you want to base the report on. Click OK. Answer the questions asked of you by the Report Wizard and proceed through. When done creating report, click on Finish.

Page 31 of 37

Grouping: You can decide to group a report by certain fields. This means that the final report will divide the table into categories of related records. For example, you can group the DeptCode field in the report and when the report prints it will be grouped by departments. Access can group up to 10 fields or expressions in one report. If using the Report Wizard to build the Report, you will have a chance to decide which field(s) you’d like to group. If you are building the Report in Design view or using an AutoReport – you will have to manually create the groups.

To create groups in a Report in Design view: 1. 2. 3. 4. 5. 6. 7. 8.

Open the Report in Design view. Click the Sorting and Grouping button on Standard Toolbar. Select the field from the field/expression column that you wish to group by. Choose a Sort Order, if necessary. In the Group Properties area, set the Group Header section to Yes. Add a Group Footer section, if desired. Close the Sorting and Grouping window. Check Report for accuracy.

Layouts & Styles: When working with the Report Wizard you can decide how you want the report to look by deciding on a Report Layout – which refers to how the data and labels are displayed on the report. There are 6 to choose from. Styles decide how the title and information in the Detail section will be displayed on the report. If creating the Report using the Report Wizard, you will have a chance to pick your desired Layout and Style. If you are creating a Report in Design view or with an AutoReport, you can change the Style by using the AutoFormat button on Standard Toolbar. Changing Report Layout is much more difficult in Design view. If you wish to change the Layout of the Report, you can either manually move and edit the controls or simply recreate the Report by using the Report Wizard.

Page 32 of 37

To change Styles: 1. 2. 3. 4. 5.

Open the Report in Design view. Select the entire Report Click the AutoFormat button on Standard Toolbar Choose the desired Style Click OK.

Report Sections: Report Wizard automatically adds a title, data and page numbers to your report. This information will be placed in specific areas of the report. These areas control where information in printed in the report

Section

Description

Report Header

information here gets printed at the beginning of the report. This is often used as the title of the report or used for a cover page.

Page Header

information here gets printed at the top of each page within the report.

Group Header

information here gets printed once at the start of each group, if groups have been defined.

Detail

the section contains the fields that you want printed in the report.

Group Footer

if you create groups, you can use this section to display summary calculations that you want performed for each group.

Page Footer

information here gets printed at the bottom of each page in the report. Page numbers are placed here a lot.

Report Footer

information here gets printed at the end of the report. Used many times to list summary calculations for all the records in the report.

Page 33 of 37

To create a Report from a Query: Basing a Report upon a Query is an easy way to include calculated fields, selected records or to print data from more than one Table. You can add calculated fields to a report after it’s been built, but it’s difficult and tedious. It’s much easier to create the calculated field in a Query, then use the Report Wizard to add the calculated field to the report. 1. 2. 3. 4. 5. 6. 7. 8. 9.

Create a new Report. Use the Wizard to design it. When asked, choose the Query you want to base the report on. Follow the Wizard, answering all needed questions. If summary information is needed, choose the Summary Options...button. Decide how you want to summarize each field. Check on the values you want calculated and how. Click OK. Finish the Wizard, choose Finish.

To apply an AutoFormat: AutoFormats are a quick and impressive way of formatting a report before printing. 1. 2. 3. 4.

From Design view, select all the components of the report. Click on AutoFormat button from Standard Toolbar. Choose the type of AutoFormat desired. Click OK.

Printing the Report: You can print a report by either clicking the Print button on the Standard Toolbar or by choosing File, Print from Menu bar. You can also press CTRL + P on keyboard to print. Printing Reports is the same as printing any other Database object.

To print a Report by using the Menu bar: 1. 2. 3. 4.

Choose File, Print from Menu bar. Choose the desired Print Range. Select the number of copies desired. Click OK.

Page 34 of 37

Importing and Exporting: Once you start building a database, there may be times when you want to copy one of the objects within your database into another database or vice versa. You can import and export data in Access with ease. In addition to importing, you can bring in other objects by linking. Linking an object keeps a connection with the imported object so that any change you make in this database will also appear in the original database.

To import database objects from other Access databases: 1. 2. 3. 4. 5. 6.

Open the database that you want to copy an object into. Choose File, Get External Data, Import... from Menu bar. Select the Access database file from which you want to get the object. Click on Import. Make sure you select the object you want. Click OK.

To import multiple objects: 1. 2. 3. 4. 5. 6.

From within the database to which you want to copy multiple objects. Choose File, Get External Data, Import from Menu bar Choose the database file from which to retrieve the multiple objects. Select the number of the objects desired.. Click OK when done selecting all the objects. View the current database for the presence of the imported objects.

To import Excel files into an Access database: 1. 2. 3. 4. 5. 6. 7. 8.

Open the Access database to which you wish to import the Excel file. Choose File, Get External Data, Import from Menu bar. Change the Files of Type area to Microsoft Excel. Find the Excel file you wish to import. Click Import button. Choose which worksheet or range of cells to import. Click Next button. If the first row of the importing object contains field names, check the First Row Contains Column Headings check box. 9. Click Next button. 10. Decide whether to import the object as a New Table or into an Existing Table. 11. Click Next button. 12. Make any necessary changes to the fields, if needed. 13. Click Next button. 14. Decide how you want to handle the Primary Key. 15. Click Next button. 16. Name the Table. Page 35 of 37

17. Click Finish button.

To export Tables as Excel files: 1. 2. 3. 4. 5.

Highlight the Table you wish to export. Choose File, Export from Menu bar. Decide where to save the Table. Choose Excel 97-2000 from the Save as Type area. Click Save.

Access will allow you to import and/or export multiple different file formats including plain text file (.txt) and HTML files (.htm).

To link tables: 1. 2. 3. 4. 5. 6. 7.

Open the database of where you wish to bring in the new linked table. Choose File, Get External Data, Link from Menu bar. Select the database of the table to which you want to link. Click Link button. Select the Tables to which you want to link. Click OK. Check the first database to make sure the linked Table appears.

To use the Link Table Manager: There will be times where Tables that you’ve linked to may move to different databases, or the databases may be moved to different locations. The Linked Table Manager allows you to view and update the location of the linked objects to that the links aren’t broken. 1. 2. 3. 4. 5. 6. 7.

Open the database in which you created the link. Choose Tools, Database Utilities, Linked Table Manager from the Menu bar. Check the link that you want to update. Click OK. Click OK again. Update any other links, if necessary. Click Close when finished.

Page 36 of 37

Compacting databases: When you delete tables or records, the database still keeps that area that those items were originally in open and unusable – which takes up valued disk space. This is called fragmentation. To reclaim the unused disk space so it can be used again, you need to compact your database.

To compact a database: 1. 2. 3. 4.

Choose Tools, Database Utilities, Compact Database. Select the database you want to compact. Click on Compact. Once you’ve compacted the database, you have the option of saving the compacted version with a new name, if desired.

Page 37 of 37