All You Ever Wanted To Know About Access (that we can cover in three hours) Instruction and Tables...
-
Upload
brendan-neal -
Category
Documents
-
view
215 -
download
1
Transcript of All You Ever Wanted To Know About Access (that we can cover in three hours) Instruction and Tables...
All You Ever Wanted To Know About
Access (that we can cover in three
hours)
Instruction and Tables Developed by Bob Thurman, Richardson ISD
Instruction Edited by Terence Peak, UIW
What You Will Learn Today
Defining Tables, Queries, Reports and FormsDatabase PlanningDeveloping Tables
From Table TemplatesManuallyFrom External DataIn the Design View
What You Will Learn Today
Setting the Primary KeyCreating RelationshipsRunning QueriesCreating FormsGenerating ReportsMaking LabelsCreating Charts
Definitions
Database: Tables, forms, queries, reports in one file.Record: A set of Data about a person or thing.Field: A category of information that pertains to all records (in a column format).Value: A single piece of data.
Source- New Horizons source booklet ; Access Level 1, Course Edition11
DefinitionsTable: A group of records and fields stored as rows and columns.Query: A question the searches a database for information.Form: A document used to input table data, arranged in an order specified by the user.Report: Graphic interface used to display the output of a table or query.Primary Key: The Primary Key is a combination of fields that contain values that uniquely define records.
Source- New Horizons source booklet ; Access Level 1, Course Edition11
Planning a DatabaseIdentify the Purpose of the Database
What do you want the database to tell you.What kinds of data will be in the database.Describe who will use the database.
Review Existing DataExisting databases, spreadsheets, documents, invoices, etc.
Determine FieldsDevelop fields to generate information that is pertinent to the database.Fields should contain smallest meaningful value.
Source- New Horizons source booklet ; Access Level 1, Course Edition11
Planning a DatabaseGroup Fields into Tables
A table should contain information on ONE SUBJECT.Too many tables is not a problem, too few is.
Normalize DataOnce a table is complete, enter data to determine whether or not the data yields good information.This process assists in determine if you are asking for information as the smallest meaningful value.
Determine Primary KeyThe Primary Key is a combination of Fields that contains values that uniquely define records.It establishes relationships between tables.
Source- New Horizons source booklet ; Access Level 1, Course Edition11
Creating a Table
Blank Database
Open Access Click on StartClick All ProgramsClick Microsoft OfficeClick Access
When the page opens, locate and click New Blank Database
Blank DatabaseLook on the right side of your screenCreate a FileNameEach word of the File Name is capitalized. Spaces may be used (in prior versions of Access, spaces were not allowed).This format us used for queries, forms and reports. Click Create
Table
A Table is a group of records and fields stored in rows and columns In a table, a row is referred to as a record, and a column is referred to as a field.
A Record is set of Data about a person or thing.A Field is a category of information that pertains to all records.
New Table
The new table opens looking like the illustration above. As with all other Office 2007 products, all of the database functions are accessed through the RibbonClick the Create tab to create a table
New TableIn previous versions of Access new tables were created using one of three methods:
Manually in the Design ViewUsing the Table WizardFrom external data
In Access 2007, tables can be created:ManuallyUsing a Table TemplateFrom (or as) a SharePoint listFrom external dataIn the Design View
Manually Create a New Table
Click the Create tabClick Table
Manually Create a New Table
By default the table has two fields ID and Add New Field. (ID will be used for the Primary Key)Double-click Add New Field to name the field
Field names should accurately describe the data entered into the fieldFields should contain smallest meaningful value
Manually Create a New Field
To add a additional fields, move the mouse to the edge of the field and click Click the New Field icon and a new field template will appear
Add Field Template
There are several categories of pre-formatted fields, Double-click on the name of the field template to add the field Continue the process until all of the necessary tables have been added.
TemplatesA table template is an empty table that you can start using as-is, or modify to suit your needs. Templates are designed to be used with Windows SharePoint Services 3.0These are the available templates:
Contacts A table for managing business contact informationTasks A table for tracking tasksIssues A table for tracking issuesEvents A table for managing eventsAssets A table for managing business assets
After you create a table by using a table template, you may want to add fields by using field templates.
http://office.microsoft.com/en-us/access/HA012242511033.aspx?pid=CH100645691033
Create a New Table from a Template
Click the Create tabChoose Table TemplatesChoose Contacts
Create a New Table from a Template
This creates a pre-formatted table containing contact information, (first name, last name, etc.)The table can be edited to remove columns (fields) that are unnecessaryNotice that ID is the first field
The ID Field
The ID field is crated by Access to provide a uniquely defined record that can be used as the Primary KeyA number is automatically assigned to the ID field once information is added to other fields within the tableThe records will be numbered sequentially
Editing a Field (Column)
There are two choices for editing fields in a table; rename or deleteRight-click on the field nameChoose rename or deleteIf renaming, remember o name the field so that the name accurately describes the information in the field
Create a Table from External Data (Excel)
Click the External Data tabChoose Excel (Data will be imported from Excel)
Create a Table from External Data
On the next page, click Browse and locate the Excel file (Data.xls)Choose Import the source data…Click OK
Create a Table from External Data
On the next page, click NextClick the box “First Row Contains Column Headings”Click NextClick Next again
Create a Table from External Data
Check the box “Let Access choose the primary key”This will add an additional field (ID), and number it to create a primary key. If a primary key is not necessary, check No primary KeyClick FinishClick Close
Edit and Create tables in Design View
To edit the database in the design view, click on table Addresses: TableClick the Home tabClick the Design View Icon
Edit Fields in Design View
Field Names are the Column headings in a data base. For example ID, First Name and Last Name areField Names can me edited in Design View
Double-click on Zipcode to select the field, and type Zip CodeRepeat to change M/F to Gender
Note the Primary Key Symbol in the ID Field
Edit Fields in Design View
Data Types denote the types of information (number, date/time, text) contained in a FieldData Types can be edited
Click on Zip CodeClick the Data Type FieldClick on the Drop Down List arrowChoose Text
Edit Field Properties in Design View
Field Properties may also be edited for content. Field Properties are below the Fiend Name and Data type tabs
Select Zip CodeClick the General TabDouble click Field Size to change the Field Size to 20
Edit Field Properties in Design View
Double-click required and change Required to Yes These edits now limit the size of the Zip Code field to 20 charactersSince Yes is selected in the Required field, the field may not be left blank when adding data to the table
Input Mask
The Input Mask allows for text added to a table in a pre determined formatSelect Zip CodeClick the General tabChoose Input Mask and click on the toggleClick Save on the pop-up menu
Input Mask
The Input mask will format numbers and spacing for
Phone NumbersZip CodesSSNsDateTime
Choose an Input MaskClick FinishZip codes will now be entered as a 10-digit format
Input Mask
Add a second Input Mask so that the Phone Number is in the proper format. Be sure to change the Data Type to TextChange the Field Size to 15
Create a Table in Design View
Click the Create tabChoose Table Design
Create a Table in Design View
The Field Name and Data Type columns open along with Table PropertiesDouble click Field Name tab to name the field Student IDChange Data Type to Auto Number
Create a Table in Design View
Field Name Data TypeStudentID Auto NumberExerciseLogID NumberWorkoutDate Date/TimeHours NumberMinutes NumberSeconds Number
Add the following Field Names and Data Types to the table
Create a Table in Design View
Click SaveName the table Workout Click OK.If asked to create the Primary Key click Yes
Create a Table in Design View
The primary key may also be set by right-clicking in the column next to the field nameChoose Primary Key from the list
Create a Table in Design View
Rows may also be added or removed by right-clicking in the column next to the field nameClick Insert Rows or Delete Rows
The Primary Key
The Primary Key is a combination of Fields that contains values that uniquely define records. It is possible to set multiple Primary Keys is a table.Relationships require a Primary Key to be set.Once you designate a primary key for a table, Access will prevent any duplicate or Null values from being entered in the primary key fields.
Types of Primary Keys
AutoNumber: This Field can be set to automatically enter a sequential number as each record is added to the table. This is the simplest way to create a primary key. Single-field primary keys: If you have a field that contains unique values such as ID numbers or part numbers, you can designate that field as the primary key. Multiple-field primary keys: in situations where you can't guarantee the uniqueness of any single field, you may be able to designate two or more fields as the primary key. Common when a table is used to relate two other tables in a many-to-many relationship.
Change Primary Key
Open the Addresses TableNotice that ID is the Primary Key, it needs to be changed to SSNRight-click on the Key IconClick Primary KeyMove to SSNRight-click on the Key IconClick Primary KeyThere must be data in new Primary key field
Relationships
Types of Relationships
One to One: An association between two tables in which one record a table relates to only one record in the other table. One to Many: An association between two tables in which one record in a table can relate to many records in the other table. Many-to-Many : An association between two tables in which one record in either table can relate to many records in the other table.
Creating Relationships
Using the current Database Student Data – Tables OnlyClick the Database Tools tabClick RelationshipsAll tables in a database must be closed to create relationships
One-to-One Relationships
The Show Table menu opens. Be sure that the Tables tab is selectedClick on the Students and click AddClick Workout and Click AddBoth tables should be in the Relationship WindowClose the Show Table menu
One-to-One Relationships
Click and drag from StudentID in the Students table to ExerciseLogID in the Workout table. Note that both fields are Primary KeysThe relationship type should be One-To-OneClick CreateClick OK
Editing Relationships
To remove a relationship, Right-click on the relationship lineClick DeleteClick YesThe relationship is removed
One-to-Many RelationshipClick on the Relationships icon on the toolbar and create a relationship between StudentID in the Students table and StudentID in the Workout tableClick Enforce Referential Integrity & both boxes below itThe relationship type is One to ManyClick Create
One-to-Many Relationship
Notice the “infinity” symbol-denoting a One-to-many relationship Save your work, then close the Relationships window
RelationshipsA relationship works by matching data in key fields - usually a field with the same name in both tables. In most cases, these matching fields are the primary key and a foreign key A foreign key indicates how the tables are related in the other table. If you want to change the Primary Key, you must first delete (remove) the relationship between the tables.
Queries
Queries
A Query is a question the searches a database for information. If a relationship is established, a query can be run from two or more databases. Queries can be fine-tuned to;
Give specific information about a data field.Summarize information over years, days or months.Review multiple tables to find duplicate information.
Running Queries
Click on the Create tabClick Query Wizard (far right on the tab)The Query menu opens, choose Simple Query WizardClick OK
Query
Choose Table: Workout , click on the Tables/Queries dropdown menuSelect the WorkoutDate and Distance fields from the Workout table By clicking the field name, then the >The field names will appear in Selected Fields Click Next
Query
Click Summary Click Summary Options
Query
Click SumClick OKClick Next
Query
Click YearClick Next
Query
Name the query WorkoutCheck Open the query to view informationClick FinishCheck your results, then close the windowThe result is a table that summarizes all of the runs for each year by total distance
Query in the Design View
Using the Design View to create quires provides additional flexibility.Queries can be modified and to generate specific results.Click Query Design
Students by Zip Code Query
Select the Students tableClick AddClick Close
Students by Zip Code Query
Click and drag these fields; StudentID, FirstName, LastName, and PostalCode to the first four columns
Students by Zip Code Query
To sort by Zip Code, click under PostalCode in the Sort rowSelect Ascending.There should be check marks under each field.
Students by Zip Code Query
Click on Run! on the ribbon to run the query.Click Save Save as Zip CodeClick OKThe result of this query is a list of all of the students sorted by zip code, lowest to highest
2001 Query
Click Query DesignClick Open.Select the Workout tableClick AddClick Close
2001 QueryClick and drag WorkoutDate and Distance to the first two fields under WorkoutDate Next to Criteria type Between 01/01/01 and 12/31/01Save the query and run it.The result is a list of all runs for 2001
Long Runs Query
Click Query DesignDouble-click the Students and Workout tablesClick CloseClick the fields window to open the dropdown menu Double-click Students:FirstName, and Students:LastNameClick and drag Workout:WorkoutDate and Workouts:Distance to the next two columns.
Long Runs Query
In the Criteria Row, in the Distance Field, type >10SaveRun the queryWhat is the result?
This or That Query
Click Query DesignDouble-click the Students tableClick CloseClick and drag FirstName, LastName, Address, City, StateorProvince, and PostalCode from the Students table to the first seven columns.
This or That Query
Under LastName type Thurman in the first Criteria row and Jones in the second Criteria row.Under PostalCode type 75243 in the first Criteria row and 75080 in the second Criteria rowSave your workRun the queryThe result is a list of everyone named Thurman or Jones who lives in the 75243 or75080 zip code
Find Duplicates in Queries
Click Query WizardSelect Find Duplicates Query WizardClick OK
Find Duplicates in Queries
Select the Workout table Under View, click TableClick Next
Find Duplicates in Queries
Select Distance Click Next
Find Duplicates in Queries
Click >> to select all fieldsClick NextClick FinishWhat is the result?
Unmatched Query
Click Query DesignSelect Find Unmatched Query WizardClick OK
Students Without Matching Workout Query
Select the Students table Click NextSelect the Workout table Click NextTables should be selected for both tables
Students Without Matching Workout Query
Click >> to select all fieldsClick Finish Close all Queries
Forms
Forms
A Form is document used to input add data to a table. It can be arranged in an order specified by the user. Forms can be developed so that someone accessing a database can input data into table, without being able to access the table.
Form Wizard
On the Create tab, choose More FormsClick Form Wizard
Form Wizard
Select the Students table, then select all fields by clicking >>Select the Workout table, then select all fields by clicking >>
Form Wizard
Deselect the StudentID field in the Workout table by clicking on it, then on <Click Next
Form Wizard
Accept the defaults by clicking Next twice.Choose FlowClick NextClick Finish
Forms
For the purposes of this class, this is a brief exercise in creating a form. Forms can be much more complicated and can be modified to perform a significant number of functionsTo see some of the options available in a form open BikCitLuis .mdb and open the BikeCity Form
Reports
Reports
A Report is the graphic or hardcopy output of a table or query. Reports are in a more legible format than a queryReports can be formatted to be easier to read and understand Data output from a report can be sorted and grouped according desired outputOutput can be as labels or as a chart
Report – Workout Total By Week
On the Create tabClick Report Wizard.
Report – Workout Total By Week
From the Students table, select FirstName and LastName, From the Workout table, select WorkoutDate and DistanceClick NextAccept the defaults Click Next
Report – Workout Total By Week
Double-click WorkoutDate as the Grouping LevelClick on Grouping Options
Report – Workout Total By Week
Select Week as the grouping intervalClick OKClick Next
Report – Workout Total By Week
Click on Summary Options, choose either Detail and Summary or Summary OnlyClick OKClick Next
Report – Workout Total By Week
Choose Landscape OrientationChoose a LayoutClick NextChoose StyleClick NextName the report Workout Total By WeekClick Finish
Labels
Click on the Students TableClick Labels in the Reports Group
Labels
Choose 5260 as a Label type Click NextAccept the defaults Click Next
Labels
Add the following fields in this format:
FirstName > <SP> > LastName
<R> > Address<R> > City <SP> > State <R> > ZipCode
Click Next
Labels
Sort by Zip Code Click NextClick Finish
Viewing Tables, Queries, Forms & Reports
Click the down arrow next to TablesSelect All Access Objects
Questions?Terence Peak, M.Ed.Coordinator of Technology TrainingBlackboard Certified TrainerThe University of the Incarnate Word(210) [email protected]