Microsoft Access 2007 - Module IObjectives At the end of this training session you should be able to: 1. Understand the three types of relationships: one-to-many, many-to- many and one-to-one; 2. Create a new database; 3. Create tables for data entry in datasheet view and design view; 4. Enter data into a table; 5. Use, understand, and set data types: text, memo, number, currency, date/time, autonumber, yes/no, lookup wizard; 6. Insert and delete a field; 7. Create and delete a primary key; 9. Create a form using the Wizard tool; 10. Create a split form.
Hillsborough Community College - Professional Development and Web Services
Microsoft Access 2007 - Module IBefore a database is developed, plan the structure from the beginning to the end. Flow-charting or blueprinting in advance will eliminate restructuring and/or starting fromscratch.Questions to Ask Before Designing a Database:1. What does the database need to do?2. What functions need to be achieved?3. Which objects (such as tables, forms) depend on each other?4. What items are needed for the database?5. Who will use the database?6. How will the output data (report) be generated?7. How will the database be organized?Access Database TerminologyIt is necessary to understand and be familiar with the basics of a database and its ob-jects to create or generate information.Table- The central framework of a database that stores data in fields (columns) and re-cords (rows).Query- Allows for table inquiries. A query can change, delete, add, arrange data intables. Also aids gathering information for forms and reports.Form- Displays and enters data in a fitted format. Forms can also contain other nestedforms (subforms).Report- Allows for the printing and print preview of information such as labels, lists,form letters, invoices, summaries, display charts, etc. The user can personalize reportsby adding a logo or picture, organizing headers, details, footers, and sorting columns.Page- Also known as Data Access Page. Allows the publication of a web page and webaccess to a database. A page can be viewed and edited.Macro- Allows for automating simple and common tasks such as opening and closing aform, exporting data, printing data in a report, and saving data.
Hillsborough Community College - Professional Development and Web ServicesWhen organizing and creating a data-base, the question, How will the ob-jects (tables) relate? must be asked. 1There are three types of relationships inMicrosoft Access: One-to-many Table 1 Many-to-many One-to-oneOne-to-many relationshipThe most common type of relationship. Arecord from one table (Table 1) can havematching records in another table (Table 22); however, Table 2 has only one match-ing record in Table 1. Table 2 3Lets look at the example. 1. One Department 2 . has more than one Course, 3. yet each Course has one Department. Many-to-many relationshipNot recommended due to problems en-forcing referential integrity. A record fromone table (Table 1) can have many match-ing records in another table (Table 2). Table 1Also, a record in Table 2 can have manymatching records in Table 1. This is possi- 3ble through the use of a third table calleda junction table. The junction table has 1 2a primary key that consists of two fieldsfrom Tables 1 and 2.Lets look at the example. 1. Primary key from Inventory Details table (tblInventDetails) Junction Table 4 2. Primary key from the equipment table (tblEquipment) 3. One department can have several types of equipment, 4. And each type of equipment can appear in several departments. Table 2
Microsoft Access 2007 - Module IOne-to-one relationshipLeast common type of relationship. How-ever, a one-to-one relationship is useful ifthere are records that must be kept confi-dential and secure. A record from one table(Table 1) can have one single matchingrecord in another table (Table 2), and Table2 can have only one single matching record 1in Table 1.Lets look at the example. 1. All students have one matching record in the 2 student table (tblStudents). 2 . The values are a subset of the social security field and the student table (tblStudents).
Hillsborough Community College - Professional Development and Web ServicesCreate a New DatabaseBefore creating tables and forms, creating ageneral database is recommended. 1. Open Access 2007. Go to Start All Programs Microsoft Office Microsoft Office Access 2007 2. You have the option to: A. Open a Microsoft template B. Open a recent database C. Open a Blank Database. For this exercise, we will choose this option. 3. Type the file name of the database. e.g. HCC_Employee_Data 4. Click Create. 2C 2A 2B 3 4
Microsoft Access 2007 - Module IAccess 2007 Tour andFeaturesThe top of the screen has been rearrangedin Access 2007. Instead of concealed 1 2toolbars and commands, you have one 3control center, called the Ribbon. TheRibbon area includes Office Button, theQuick Access Toolbar, tabs, groups andcommands.Ribbon Area 4 1. Select the Office Button to access most of what used to be under the File menu, such as Open, Save and Print. 5 2. The Quick Access Toolbar includes buttons to Save, Undo and Redo. You can customize this toolbar by adding your favorite commands. Just click the down arrow to the right of the Redo button. 3. Tabs include Home, Create, External Data, Database Tools and Datasheet. Tabs, such as Table Tools will appear when you are working on a related task. 4. Groups include related commands. For example, the Font group includes the buttons for font type, font size, font color, alignment, etc. 1 5. Commands are the actual task buttons, such as Bold, Underline, Italicize, etc. Examples of New Features 1. Database Templates 2 2. Split Form 3. Enhanced Datasheet View 4. Memo fields support rich text 5. Attachment data type
Hillsborough Community College - Professional Development and Web ServicesCreate a Table In DatasheetViewCreating a table in Datasheet View givesyou access to the field names (dataheadings), data types and the actual data. 1 1. When you first open a Blank Database, a new table is created for you. To create one yourself, go to the Create tab. Under the Tables group, 3 select Table. 2. The default view for a new table is Datasheet view. The first field (column) is automatically 2 4 named ID, the data type is AutoNumber and it is the assigned Primary Key. You can delete or edit this field, if your table does not need an ID field. For now, let’s leave it there. We will use it later. 5 3. Double click on Add New Field and type in the new field name of LastName. When entering field names, do not use spaces or punctuation. 4. Type in Smith, in the first row under the new heading of LastName. 5. The Data Type is set to Text. If you had typed in numbers, the data type would have been Number. If you need to change data types, click on the down arrow in the box next to Data Type to make your selection. Go to the Data Type section in this booklet for descriptions or hit F1 on your keyboard for more details and help on data types. Primary keys are not required; however, they are needed to create relationships between tables in a database. Primary keys cannot be duplicated; therefore, never use a last name, address, or a field where information is likely to be repeated. Ideal primary keys are employee numbers, social security numbers, product numbers, etc.
Microsoft Access 2007 - Module IEdit a Table In Design View 1Creating or editing a table in Design Viewgives you freedom to construct a table withspecifications for data collection. You donot type in the actual data in this screen.You are setting up the table structure -field names, data types, field size, datavalidation, etc. 2 1. The default view for a new table is Datasheet view. In the Home tabViews group, select the Design View button to switch to Design View. 2. If prompted, save your table as tblEmployeeInfo. 3. To add or edit fields, type in the Field Name column. When entering field names, do not use 3 spaces or punctuation. 4 4. Under Data Type, click on the down arrow and select an appropriate data type. Go to the Data Type section in this booklet for descriptions or hit F1 on your keyboard for 5 more details and help on data types. 5. You can set more specific settings for your data 6 types in Design View. For example, locate the General tab and type 20 for the Field Size of LastName. Typing in 20 for the field size indicates that the last name can be no more than 20 characters long. 6. Type a label for the Caption. e.g. Last Name: Spaces and punctuation can be used for captions. Whatever is typed in the caption will appear in both forms and reports. If no caption is entered, the field name will appear instead.ActivityAdd the following fields to the table, FirstName,MI (middle initial), Street, City, State, Zip, Exempt,Phone and Campus. Also add the Field Size and Cap-tion for each field name.
Hillsborough Community College - Professional Development and Web ServicesSave a Table 1Saving a table with a specific title will help 2when organizing information, creatingqueries, forms, and pages, and connectingto other tables. 1. To save the current table, click the Save button in the Quick Access Toolbar. 2. You can also get to a Save button through the Office Button. 3. You can use Save As, from the Office Button to rename the database, save a copy or to save it in another format, such as in a previous version. 310
Microsoft Access 2007 - Module IEnter Data into a TableOnce a table has been created, data can beentered. 2 1. If your new table is not open, double click on its title, in the Navigation Pane. 2. In the Home tabViews group, select Datasheet View. 1 3. Under FirstName, type in new data. e.g. Sue 4. Type in data for MI, Street, City and State. 5. Click Save. 4 3ActivityCreate a new table, tblCampus. Add one field to thetable, Campus. Open the table and add the data, BR,DAO, DM, MacDill, PC, SPC, YB. 11
Hillsborough Community College - Professional Development and Web ServicesData TypesIt is important to assign appropriate data types to a field since they specifywhat type of data can be entered into a field.Data Type DescriptionText Can contain any entries that do not require calcula- tions such as addresses, social security numbers, dates, and phone numbers. Maximum number of characters, including spaces, is 255 characters.Memo Long text or number entries. Use when more than 255 characters are necessary.Number Can contain only numbers. Can be positive or nega- tive. Used for calculations.Currency Can contain only monetary data. Can be used in cal- culations.Date/Time Add date and time. 8 character default.AutoNumber Use when sequential, random, or replication ID num- bers are needed.Yes/No Use when Yes/No, True/False, or On/Off are neces- sary.OLE Object Add objects such as Excel workbooks or Word docu- ments that are linked or embedded.Hyperlink Link to files, objects or web links.Lookup Wizard Use when choosing data such as tables or a list of values.Attachment Can contain an attached file, such as images or doc- uments.12
Microsoft Access 2007 - Module IUse Input Mask WizardThe Input Mask Wizard allows thedesigner to define the format for enteringdata. In this example, a format is set forentering a zip code. To use the input maskwizard the table must be in Design View. 1. If you don’t have the Zip field yet, type Zip under the Field Name column. 1 2 2. Select Text for Data Type. 3. Type Zip: for the Caption. 4. Click in the field property for Input Mask. 4 5 5. Click on the build button. The Input Mask 3 Wizard appears. 6. Select Zip Code and click on Next. 7. You can alter the mask and select a placeholder, if you would like. When your changes are complete, click on Next. The underscore _ is the default placeholder character. 8. Click on the With the symbols in mask radio 6 button. 9. Click Next and Finish. Notice that the mask is added under Field PropertiesInput Mask. 10. Now all entries in the zip code field will have to follow this format. Go to the Datasheet View to test out the mask. 7 8 13
Hillsborough Community College - Professional Development and Web ServicesData Type: Yes/NoData types are used to specify what type ofdata can be entered and stored into a field.In this example, the Yes/No data type isused for Exempt. Using the Yes/No formatis helpful for simple, clear-cut answers. Youcan edit data types in either DatasheetView or Design View. We’ll use DesignView. 1 1. If necessary, enter the Exempt field under the Field Name column. 2. Under Data Type, click on the down arrow and select Yes/No. 2 Go to the Datasheet View. Yes is represented by a check and No is not checked in the Datasheet View. 3. Select Yes, if you are prompted to save the table. 4. Select Yes, if you are prompted that you may lose data due to the data type change. 5. Test and view the yes/no format in the Exempt field. 3 4 Yes/No also represents the following: True/ False, 1/0, and On/Off. 514
Microsoft Access 2007 - Module IData Type: Lookup WizardThe purpose of the Lookup Wizard is toconnect one field from one table to anothertable or a list of values. Using the LookupWizard is useful when choices need to belimited.For instance, Hillsborough CommunityCollege has the campus location of DistrictAdministrative Offices. If members ofthe HCC community were to type District 1Administrative Offices in a table, theycould type GK, DAO, District AdministrativeOffices or some other spelling/misspelling.Therefore, restricting the location to DAOensures the same information is entered.In this example, a drop-down menu iscreated by using the Lookup Wizard,which will connect to tblCampus. 2To use the Lookup Wizard the table mustbe in Design View. 1. If necessary, type in the Field Name. e.g. Campus 3 2. Under Data Type, click on the down arrow and select Lookup Wizard. 3. A Lookup Wizard dialog box appears. Click on the I want the lookup column ... radio button. 4. Click on Next. 4 5. Select the table for the lookup. e.g. Table: tblCampus 6. Click on Next. 5 6 15
Hillsborough Community College - Professional Development and Web Services 7. Select the available field(s) to include by selecting the field(s) and clicking on the single- headed next arrow. e.g. Campus 8. Click on Next. 7 9. Set sort order as needed and click on Next. e.g. Campus, Ascending 10. Select Hide key column and click on Next. 11. After entering the label name for the lookup 8 column, click on Finish. e.g. Campus 12. Click Yes to save table and create relationships. To view the down-drop menu for the different campuses, click on the Datasheet View button. 9 To manually add a drop down menu, select Lookup Wizard... as the Data Type. Select I will type in the values I want and follow the wizard. 10 Activity Use the Lookup Wizard to connect the field name State to a table called tblState or manually add a lookup for State. You do not need to include every state. 1116
Microsoft Access 2007 - Module IInsert and Delete FieldsAfter a table is created, additional fieldnames may to be added or deleted. 2In this example, we are adding anEmployeeID (employee number) field.To insert a field into the table, go to Design 1View. 1. Click on the row below where the field is to appear. In this example, click on the field name LastName. 3 2. In the TableTools/Design tabTools group, click on Insert Rows. 3. Type in the Field Name and Data Type e.g. Field Name: EmployeeID Data Type: Text Field Size: 7 Caption: Employee ID: The data type is set to Text because this data doesn’t require any calculation. 4. To delete a field name, select the row and press the Delete Rows button in the Tools group of the Design tab. 5. Go to Datasheet View and enter in a unique EmployeeID for each employee. 4 In Datasheet View, the Insert command is on the Datasheet tab, in the Fields Columns group. 5Activity1. Insert a field of your choice. Choose an appropriate Data Type. Enter the Caption for your new field.2. Delete the Phone field. 17
Hillsborough Community College - Professional Development and Web ServicesSet a Primary KeyPrimary keys uniquely identify each record 2in a table. An advantage of a primarykey is that it does not allow duplicationof information. Access does not require 3a primary key and multiple primary keyscan be set. Select a primary key when youneed to create relationships between tablesin a database. Primary key data cannot 1be duplicated; therefore, never use a lastname, address, or a field where informationis likely to be repeated. Ideal primary keysare employee numbers, social securitynumbers, product numbers, etc. 4In this example, a primary key is set forthe Field Name: EmployeeID.To set a primary key, the table must be inDesign View. 1. Click on the row selector for the field to be set as a primary key. e.g. EmployeeID. 2. Select the Design tab. 3. Press the Primary Key button. 4. If the there is more than one primary key, press and hold down the Ctrl key, and click on the row selector for other fields. With the appropriate rows selected, press the Primary Key button. e.g. EmployeeID and ID. Ideal primary keys are employee numbers, social security numbers, product numbers, etc.18
Microsoft Access 2007 - Module ICreate a Form: Form WizardThe Form Wizard is simple and easyto use. A form is used to simply displayand enter data in a fitted format. Formsin Access are created from tables and/or 1queries. Forms can also contain subforms(nested tables).Personalize forms in Design View orLayout View by adding a picture, headeror footer. Switch between views on theForm Layout Tools/Format tab. 1. In the Create tabForms group, select More FormsForm Wizard. 2 2. Select the table or query for report, for example, tblEmployeeInfo. 3. Add Available Fields to Selected Fields and 3 click on Next. In this example, add all available fields by clicking on the double arrow. 4. Choose a layout and click Next. In this example, the Columnar layout is chosen. 4 19
Hillsborough Community College - Professional Development and Web Services 5. Select the form style and click on Next, for example, Access 2007. 6. Give the form a title, for example, frmEmployeeInfo. 5 7. Choose whether to Open the form to view or enter information or Modify the forms design, for example, Open the form to view or enter information. 8. Click Finish. 9. The employee information form now appears. In this example, a form was created using the table tblEmployeeInfo. When information is added or changed through the form, the table tblEmployeeInfo is automatically updated. 6 9 7 820
Microsoft Access 2007 - Module ICreate a Form: Split FormWith some tasks, it may be helpful to viewthe form and the datasheet simultaneously. 1. In the All Access Objects pane, select the object that you would like to use for creating the form. For example, select tblEmployeeInfo. 2. Under the Create tabForms group, select Split Form. 3. You can now see a form and datasheet based on 1 tblEmployeeInfo. Data can be added, edited and deleted from the new split form. 2 3ActivityCreate a new database and form with fields of yourchoice. Use a variety of data types, such as text,number, yes/no, date/time, currency and lookup. 21
Hillsborough Community College - Professional Development and Web Services22