© 2001 ComputerPREP, Inc. All rights reserved.
© 2001 ComputerPREP, Inc. All rights reserved.
• Describe table relationships
• Relate tables
• Enforce referential integrity
• Print table relationships
• Relational database – a database that contains multiple tables related through common fields
• Relationship – a connection between two or more tables based on a common field
• By creating table relationships, you can:
– View and work with data stored in multiple tables
– Create queries and reports that display data from related tables
– Create forms to enter and view information stored in related tables
(cont’d)
• Key components that allow a relationship to work:
– Common field – a field contained in two or more tables that forms a connection between the tables
– Primary key – a field containing a value that uniquely identifies each record
– Foreign key – a field in a related table that refers to the primary key in another table
(cont’d)
• Three types of relationships can be established between tables:
– One-to-one – each record in Table A has only one matching record in Table B, and vice versa
– One-to-many – a record in Table A has many matching records in Table B; a record in Table B has only one matching record in Table A
– Many-to-many – a record in Table A or Table B has many matching records in the other table
(cont’d)
• A one-to-many relationship is the most common table relationship
• A one-to-one relationship (which is very uncommon) can be used to:
– Divide an extremely large table
– Isolate part of a table for security reasons
– Store information that applies only to a subset of the main table
• A many-to-many relationship is established by creating two one-to-many relationships with a junction table
• Use the Table Wizard or the Relationships window to create table relationships
• The Table Wizard displays a series of dialog boxes in which you enter selections for a new table
• To relate tables in the Relationships window:
– Click the common field in the primary table (the primary key)
– Drag it to the common field in the related table
(the foreign key)
• Referential integrity – rules to ensure relationships between records in related tables are valid
• Override rules against changing or deleting records and still maintain referential integrity by enabling:
– Cascade Update Related Fields – changing the primary key value in the primary table updates the matching value in all related records
– Cascade Delete Related Records – deleting a record in the primary table deletes all related records in the related table
• You can print table relationships using the
Documenter window
• The Documenter window is accessible from:
– Within a table
– The database window
– The Relationships window
© 2001 ComputerPREP, Inc. All rights reserved.
• Use the Lookup Wizard
• Modify lookup fields
• Add data to related tables
• Use subdatasheets
• Data you enter into related fields must match the data in one or more related tables
• Access offers two techniques to display data from related tables in datasheet view:
– Lookup field – a combo box that displays a list of values from a related table
– Subdatasheet – a small datasheet, which is part of the primary table’s datasheet, and displays information from a related table
• You use the Lookup Wizard to create lookup fields and value lists
• When you create a lookup field, a relationship is established between two tables
• You can modify a lookup field’s properties by setting its properties in the Lookup card of the table Design window
• A value list is a static list of values that display in a drop-down list
• Display the Lookup card in the Field Properties section of the table Design window
• Lookup field properties determine:
– Which value is stored in the lookup field
– What displays in the lookup field drop-down list
• You can use lookup fields and value lists to add data to related tables
• To add data using lookup fields and value lists:
– Display the lookup field drop-down list that contains values from the related table, or display the value list drop-down list
– Select the desired data
• Any updates you make to the table containing the primary key values will be reflected in the lookup field
• You can insert, remove, expand, collapse and print subdatasheets
• Add data in a related table by:
– Clicking the plus sign (+) to expand the subdatasheet
– Entering information
– Clicking the minus sign (-) to collapse the subdatasheet
© 2001 ComputerPREP, Inc. All rights reserved.
• Create subforms
• Display information with subforms
• Add records to a table using subforms
• Subform – a form embedded within another form
• Subforms display data from tables or queries that have a one-to-many relationship with the record displayed in the main form
• The main form and the subform are linked by the foreign key field
• The subform displays only records that relate to the record currently displayed in the main form
• A form can have any number of subforms
• You can nest as many as ten levels of subforms
• You can specify more than one table as the record source for a form or subform
• Create subforms by:
– Using the Form Wizard as you create a new form
– Using the SubForm Wizard
– Using the Subform button in the Toolbox
– Using the drag-and-drop technique
(cont’d)
• Using the SubForm Wizard:
– Access automatically links the main form and the subform if the linking fields have the same kind of data, data type or field size
– The linking fields do not have to appear in the main form or subform
• Using the drag and drop technique:
– The main form and the form to be used as the subform must exist in the Forms object list
• You can display a subform as a:
– Datasheet – multiple records, one line per record
– Single form – one record
– Continuous form – multiple records
• You can view a subform in:
– Datasheet view
– Form view
• You can change the layout of a subform in:
– Datasheet view
– Form view
– Design view
• When you enter data into the main form:
– The data is automatically saved to the primary table as you move to the subform
• When you enter data into the subform:
– The data is automatically saved to the foreign table as you add the new record
© 2001 ComputerPREP, Inc. All rights reserved.
• Review field properties
• Use input masks
• Set required properties
• Use validation rules
• Every field has properties
• Properties are different depending on the field type
• Properties that display for a given field are determined by the field’s data type
• Field properties can have overlapping effects
• Input Mask – determines what kind of data and how many characters you can enter into a field
• Input Masks have three sections:
– The input mask itself
– A character that determines whether or not literal characters are stored within the data
– The placeholder character
• Create input masks by:
– Using the Input Mask Wizard, or
– Typing in the Input Mask text box in the Field
Properties section of the table Design window
• Setting the Required property ensures that users enter data for a field
• If a field is a primary key field, data must be entered whether or not the Required property is set
• If the Required property is enforced at the table level; data is validated when entered:
– In the table
– In forms
– In datasheets based on the table
• You can set validation rules for fields and records
• Set validation rules in table Design view so they will apply in both Datasheet and Form views
• A field validation rule is used to check the value entered into a field during data entry
• A record validation rule controls when an entire record can be saved
– Record validation rules, unlike field validation rules, can refer to other fields in the same table
© 2001 ComputerPREP, Inc. All rights reserved.
• Add pictures to records
• Use calculated controls
• Improve accuracy in forms
• Bound control – a control that displays data from the form’s underlying table or query
• Unbound control – a control that is not tied to fields in an underlying table or query
– Examples of unbound controls – labels, text boxes, option buttons, command buttons and lines
• Calculated control – an unbound control that calculates values in a form, such as totals, averages and so forth
• Bound object frame – a bound control you use to display a bound object, such as a photograph, which is tied to a record in a table
• To add pictures to a record:
– Add a field with the OLE Object data type
– Add a graphic file to the OLE Object field for a given record
– Insert a bound object frame into a form to display the graphic
• To create a calculated control:
– Insert an unbound text box control into a form
– Display the Data properties for the unbound text box control
– Type an expression in the Control Source text box or
– Use the Expression Builder to build an expression in the Control Source text box
• Use an identifier to refer to an object or its properties
• The identifiers Forms and Reports refer to the open forms or reports in the database
• The ! operator indicates that the object which follows is a user-defined object
• Examples:
– Forms![Vehicles] refers to the Vehicles form
– Forms![Vehicles]![Cost] refers to the Cost field in the Vehicles form
• Use the builtin shortcut key CTRL+’ to insert the value from a field in one record into the same field in the next record
• Set the tab order so that the insertion point moves from field to field in an orderly manner as you add data to a form
• Exclude controls from the tab order for controls that should not be used in data entry, such as calculated controls
© 2001 ComputerPREP, Inc. All rights reserved.
• Create a report using the Report Wizard
• Customize headers and footers
• Concatenate text fields
• Add calculated values
• Force pagination
• Work with subreports
• The Report Wizard presents a series of dialog boxes that guide you step by step through the creation of a new report
• You can specify:
– The tables and queries to use as data sources
– The fields to include in the report
– How to group the data
– The order in which the records appear within each group
– The page layout and orientation
• Customize header and footer sections by:
– Adding bound, unbound and calculated controls
– Opening, closing and resizing report sections
– Adding page numbers and time and date stamps
• Page numbers and time and date stamps are found on the Insert menu in report Design view
• Page and report headers and footers must be added in pairs
• If you do not want a header or footer to display, close its section
• Concatenating text fields combines text values from multiple fields and displays it as a continuous string
• Use the ampersand (&) operator in an expression to concatenate values from text fields
• Concatenated fields:
– Occupy less room in a report
– Are generally easier to read than separate fields
• If you use the Report Wizard to create a report, you can group information and perform calculations, such as subtotals and averages, for each group
• You can also create calculated controls in Design view
• Using page breaks:
– In report Design view, click the Page Break button in the Toolbox
– Click in the desired report section
• Using the ForceNewPage property:
– In report Design view, display the All properties for the section
– In the Force New Page text box, select a property setting from the drop-down list
• Subreport – a report that is inserted into another report, called the main report
• The subreport control must be linked to the main report in order for the report to be synchronized
• Use the Subreport Field Linker dialog box to link reports that are not automatically linked because:
– The tables/queries are not part of a defined relationship
– The main report is not based on a primary table/query and the subreport is not based on a foreign table/query
© 2001 ComputerPREP, Inc. All rights reserved.
• Join tables in a query
• Perform calculations in a query
• Display special records
• If tables are related, they will automatically be joined by their common fields in the query Design window
• If tables are unrelated, you will have to join them in the query Design window
– Joining unrelated tables applies to tables only for the current query; it does not create a permanent join
• Two join types:
– Inner join – displays rows where joined fields from both tables are equal
– Outer join – displays all rows from one table and only matching rows from the other table
• You can add calculated fields to a query that are not part of an underlying table
• To perform a calculation in a query:
– Use totals, or
– Use custom calculations you define
• Total – a pre-defined expression that calculates a specific value from table data
– Use totals to compute the sum, average, count, minimum, maximum, standard deviation or variance for records
(cont’d)
• To perform more than one calculation for a particular field, duplicate the field as many times as necessary in the query design grid
• To perform a custom calculation, create a calculated field in the query design grid
– Calculated field – a field defined in a query that displays the result of an expression rather than data stored in a table
• You can design queries that display:
– Records containing unique values
– Records based on whether or not they contain values in a specified field
• You can use two expressions to select records based on whether or not they contain values:
– Is Not Null – used to select records that contain values in a specified field
– Is Null – used to select records that do not contain values in a specified field
© 2001 ComputerPREP, Inc. All rights reserved.
• Use crosstab queries
• Use parameter queries
• Use action queries
• Optimize queries using indexes
• Crosstab query – a query that displays summarized values in a table format
• Crosstab queries contain rows, columns and summary fields
– Summary fields display at row/column intersections and display values calculated using a summary function (average, count, sum and so forth)
• Parameter query – a query that prompts the user for specific criteria every time the query is executed
• Specify the order of parameters in the Query
Parameters dialog box
– The parameter order controls the order in which the prompts display when the parameter query is executed
• The four types of action queries are:
– Append query – a query that adds a group of records from a table at the end of another table
– Delete query – a query that deletes records from a table
– Make-table query – a query that creates a new table from all or part of the data in an existing table
– Update query – a query that makes global changes to a group of records in a table
• Use an update query to make changes to multiple records in one operation
• To create an update query:
– Create a select query
– Convert the select query to an update query
– Run the update query
– Check the results by converting the update query back to a select query and running it
• Use a make-table query to create a new table from all or part of the data in an existing table
• Make-table queries are helpful for:
– Creating a table to export to another database
– Creating a table to show information from a specific point in time forward
– Creating a backup copy of a table
– Creating a history table that contains old records
• Use an append query to add records from one table to another table
• The following rules apply to append queries:
– If the existing table has a primary key field, the records you add cannot contain Null values or duplicate primary key values of records already existing in the table
– The table to which you will add records must exist
– If you use the asterisk (*) field, you cannot also use individual fields from the same table
– If the appended records have an AutoNumber field, do not include an AutoNumber field in the design grid if the existing table has an AutoNumber field as the primary key field
• Use a delete query to delete records from tables
• To delete records from multiple tables, do the following:
– Define relationships between the tables
– Turn on Enforce Referential Integrity for the joins between tables
– Turn on the Cascade Delete Related Records option for the joins between tables
• Index – a feature that helps Access search, find and sort records
• You can optimize the performance of a query by:
– Indexing any field used to set criteria for the query
– Indexing fields on both sides of a join
© 2001 ComputerPREP, Inc. All rights reserved.
• Create charts
• Customize charts
• Chart – a graphical representation of numerical information that you can use in a report, form or data access page
•
You can use the Chart Wizard to create a chart based on an existing table or query
• A few basic rules when working with charts:
– Select the fields containing the data to be charted
– Include the fields containing the labels that identify the data
– Include any linking fields if you want the data to change from record to record
• To customize a chart, double-click on the chart in
Design view to open Microsoft Graph 2000
• Microsoft Graph 2000 displays two windows:
– Datasheet window – spreadsheet of the data used in the graph
– Chart window – displays the chart
• You can change data in the datasheet window to make temporary changes to a chart
• You must change data in the underlying table or query to make permanent changes to a chart
(cont’d
• Use the chart window to customize charts
• Cosmetic changes you can make include:
– Changing the chart size
– Changing the text attributes
– Modifying chart objects with colors and patterns
– Moving and modifying the chart legend
– Changing the chart type