Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Microsoft Access Tutorial Lesson 1: General Introduction ................................................ 3 Introduction ..................................................................................................................................... 3 Database Terminology .................................................................................................................... 3 Starting Ms Access .......................................................................................................................... 5 Designing a Database ...................................................................................................................... 5 Creating a New Database ................................................................................................................ 6 Exiting Ms Access........................................................................................................................... 7 Lesson 2: Databases and Tables ................................................ 8 Opening an Existing Database ........................................................................................................ 8 Creating Tables ............................................................................................................................... 9 Creating relationships between tables ........................................................................................... 16 Adding Records to a Table ............................................................................................................ 20 Deleting Data in a Record ............................................................................................................. 21 Changing the width of a column/Moving a column ...................................................................... 22 Finding Records ............................................................................................................................ 23 Filtering and Sorting Records ....................................................................................................... 25 Sorting ........................................................................................................................................... 26 Exercise ......................................................................................................................................... 28 Lesson 3: Queries .................................................................. 32 Introduction to Queries.................................................................................................................. 32 Creating and Saving Queries ......................................................................................................... 32 Complex Queries........................................................................................................................... 34 Creating Complex Queries ............................................................................................................ 35 Print the Resulting Data in a Query ............................................................................................. 37 Query Types .................................................................................................................................. 38 Creating Total Queries .................................................................................................................. 38 Exercise ......................................................................................................................................... 41 Lesson 4: Forms .................................................................... 42 Features of a Form......................................................................................................................... 42 Creating Forms Using the Form Wizard ....................................................................................... 42 Creating Forms Using Auto form.................................................................................................. 43 Creating a Form Using Design View ............................................................................................ 45 Opening a Data Entry Form .......................................................................................................... 45 Customising a Form ...................................................................................................................... 45 Object Linking and Embedding (Ole) ........................................................................................... 46 Creating Unbound Controls .......................................................................................................... 47 Calculated Unbound Controls ....................................................................................................... 48 Data Protection .............................................................................................................................. 53 Editing Data in a Form .................................................................................................................. 53 Exercise ......................................................................................................................................... 54 Page 1 of 83 Lesson 5: Reports ................................................................... 56 Creating Reports Using a Wizard ................................................................................................. 56 Creating Reports Using Design View ........................................................................................... 62 Sections of the Report ................................................................................................................... 64 Previewing and Printing Reports .................................................................................................. 65 Reports Based In Multiple Tables ................................................................................................. 68 Report Printing .............................................................................................................................. 71 Exercise ......................................................................................................................................... 71 Ms Access Project ........................................................................................................................ 72 Page 2 of 83 Introduction to Ms-Access Lesson 1: General Introduction 1.0 INTRODUCTION Microsoft Access is a Windows based application. It helps in storing information about different subjects in separate tables. It allows for creation of forms, which automate tasks, queries and reports that help analyse data. Benefits 1. Faster Retrieval of information 2. Analysing data using queries and producing reports for management purposes 3. Security using a Login password to prevent unauthorised access of data 4. Consistency because data is stored in a central place and is not scattered in different places 5. Data sharing by people different departments through the Local area network(LAN) The main focus of Ms Access is the Tables otherwise known as files. Tables Consist of Fields (attributes) and are used to store data e.g An Employees Table. Database Terminology Data The material (Stuff) that Access stores, organises and manages for you Fields The place where data is placed within the database is called a field. One field holds one piece of data. If you are storing student details, possible fields would include Name, Admission number, Age… Records All the fields for one student constitute a record, Records ensure which name relates to which admission number, age Table A collection of records that describe similar data is called a table. A database for student details could have tables for admission information, fees, and exams… Page 3 of 83 Index An index speeds up queries on the indexed fields as well as sorting and grouping operations. For example, if you search for specific employee names in a LastName field, you can create an index for this field to speed up the search for a specific name. Internally, an index is implemented as a look up list much like the Index you use to find information about a particular item in a book. Primary Key A field created in a table to UNIQUELY identify records. For example the NationalID number field has a unique value for every employee and therefore can be used as a primary key. Primary keys are needed to aid in searching for records. This is because a field such as the Employees Name is likely to contain similar names for different people. This means that it is more prudent to invent a series of codes (Usually Numerical) to identify the employees uniquely. Page 4 of 83 1.01 Starting MS Access Start windows and then click Microsoft Access icon to run the application or Select the program from the Program listing in the Start menu as shown below Designing a database A database is a collection of related data. 1. Determine the purpose of the database. This helps in deciding the facts to be stored. 2. Determine the tables. Divide the information into separate subjects, such as employees or orders. Each subject will be a table in the database. 3. Determine the fields. Decide what information to store in each table. Each field is displayed as a column in the table. NOTE When you create a Microsoft Access database, you create one file that contains the data and table structures as well as the queries, forms, reports, macros and modules. Page 5 of 83 1.02 CREATING A NEW DATABASE Once you have loaded the Ms Access application, you will see a dialog similar to the following: (If it is not visible: From ‘View’ Choose ‘Tool Bars’ then ‘Task Pane’) The Part Marked ‘C’ enables you to create a blank new database NB: A database file must be saved before it can be used and you will be prompted to save the file first i.e To create a new database: a) Choose ‘Blank Database’ as shown in ‘B’ on the Picture above. Alternatively: b) You may click on the ‘New’ Icon ( ) Either way you will get the ‘Save’ dialog box as shown below. Type the name of the Database and click on the ‘Create’ Button. Page 6 of 83 NB The database window is named after the name of the database that you have created. Thus: 1.03 Exiting Ms Access Page 7 of 83 1. Before exiting Ms-Access, ensure that all your tables and other database objects (new or ones to which you have made cahges) are saved, if they are not saved you will get a dialog similar to the one below 2. You need to be sure of the choice that you will make since it may have implications on the data that you have stored in the database 3. Once all database objects are closed, you may close the database window by clicking on the exit ( ) button 4. Exit ms-Access by choosing “Exit” from the “File” menu Page 8 of 83 Lesson 2: Databases and Tables 2.01 Opening an Existing Database The part marked ‘A’ (See Picture Above) shows a list of existing databases that you opened in the recent past. This list will be different for different system users (If you are using Windows XP or 2000). By clicking on either of the names in the list, you will be able to open the chosen database. To open a database that is not listed, you may choose ‘Open’ from the ‘File’ menu i.e. You may also use the ‘Open’ Icon ( A Page 9 of 83 ) Either way you will get the ‘Open’ dialog box from where you must choose the source of the file i.e. Choose the file you want to open and click on the ‘Open’ button 2.02 creating tables TABLES Creating a new table 1. Determine the fields you would like to include in the table 2. Select the Tables option and click on the New button 3. Select Design view 4. Tables are created when you want to store information that is not stored in an already existing table e.g. when you want to customers and you only have a ‘Products’ table. Page 10 of 83 Click on the ‘OK’ Button as shown above. This results in the display of a design window for the new table. It is here that you define the fields associated with this table; their names, data types and descriptions. Each field within a table has a name. This name can be up to 64 characters long, and can include letters, numbers and spaces. Page 11 of 83 The following is a summary of all the field data types available in Microsoft Access, their uses, and their storage sizes. Field Properties Text Stores text or combinations of text and numbers, such as addresses, numbers that do not require calculations, such as phone numbers, part numbers, or postal codes of size up to 255 characters. Memo Stores lengthy text and numbers, such as general notes or detailed descriptions. Memo fields hold up to 64000 characters of information. Number Numeric data to be used for mathematical calculations, except calculations involving money (use Currency type). Set the Field Size property to define the specific Number type. Date/Time Stores Dates and times Page 12 of 83 Currency Currency values. Use the Currency data type to prevent rounding off during calculations. Accurate to 15 digits to the left of the decimal point and 4 digits to the right. AutoNumber Unique sequential (incrementing by 1) or random numbers automatically inserted when a record is added. Yes/No Fields that will contain only one of two values, such as Yes/No, True/False, On/Off. OLE Object Objects (such as Microsoft Word documents, Microsoft Excel spreadsheets, pictures, sounds, or other binary data), created in other programs using the OLE protocol, that can be linked to or embedded in a Microsoft Access table. You must use a bound object frame in a form or report to display the OLE object. Field properties Depending on the nature of the contents of your field, a certain level of control can be achieved such that a field will accept what it has been programmed to have. The following options are offered: FIELD SIZE Allows entry of field size for Text data type For example, if the standard length of names is 25 characters, you may use this property to limit the number of characters entered into such a field to 25. In this case, if there are existing names longer than 25 characters then they will be truncated to 25. For numeric data types, you choose the field size by selecting from a drop-down list. Field size does not apply to the Date/Time, Yes/No, Currency, Memo or OLE object data type. FORMAT Allows selection of a predefined format in which to display the values in the field from the dropdown combo list applicable to the data type that you chose (Except Text). One can also customise a form of presentation of data. E.g. to have a code appearing before every telephone number you wish to enter, select the relevant field and set the format: “02-”000000 (This gives the code for Nairobi) Page 13 of 83 DECIMAL PLACES Can select specific number of decimal places from the drop-down combo list, and applies only to number and currency fields. INPUT MASK Helps put a mask for controlling the entry e.g. setting a limit especially to the entry of numeric fields: 000000 Will allow a six digit number no more than that or less. 999999 Will allow six or less digits. CAPTION This is a name used (other than the field name) to appear in the field name header button in Table datasheet view. DEFAULT VALUE Allows setting of a value, which will automatically be entered into the field when a new record is added to a field. E.g. Setting default date as current date: =Date() VALIDATION RULE Validation rules test the value entered in a field against set criteria. E.g. Like “Jordan” <10000 >=5000 AND <=10000 : Will only accept the word Jordan : Any value less than 10000 : Entry of between 5000 and 10000 VALIDATION TEXT Provides a message. It appears in response to violation of validation rule. It must be typed in earlier. REQUIRED Controls the entry of important fields. A YES option ensures a field is not left blank and is equivalent of typing IS NOT NULL as a field validation rule (Not necessary for primary keys since Access does not allow null value in primary key fields). ALLOW ZERO LENGTH Applies to the Text and Memo field data types. Setting the value of Allow zero length property to Yes and the Required property Yes, the field must contain at least one character. A Zero-length string (“ “) and the Null value are not the same. Page 14 of 83 INDEXED [Yes (Duplicates OK)] - Gives sorted indexed field and can allow data duplicates. [Yes (No duplicates)] - Gives sorted, indexed but cannot allow data duplicates. It’s not available for Memo or OLE data types. NEW VALUES Applies only to AutoNumber fields. Access can increment the Autonumber field by one for each new record, or fill in the field with a randomly generated number, depending on the new values property setting that you choose. NB For more details on fields and Field properties, press F1 to access help. To switch between ‘design’ and ‘datasheet’ views: 1. Move to the ‘View’ option 2. Choose the appropriate view i.e. Design or Datasheet Example of Table (Design View) In this view you can make changes to the database design e.g. adding new fields, changing field types and or/ attributes Once you finish designing the table, click on the save icon ( ), the following dialog comes up Page 15 of 83 Type an appropriate name e.g. ‘Customers’ then click on the ‘Ok’ Button ensure that the new name is not given to an existing table. You will be prompted to define a primary key IF you have not already defined one i.e 1. If you answer ‘Yes’ the table will be saved but Access will add a new field named ‘ID’,‘ID1’…. Of type ‘AutoNumber’ and make it to be the primary key. 2. If you answer ‘No’ the table will be saved with no primary key defined i.e. ‘As it is’ 3. If you answer ‘cancel’ the new table will not be saved. Example of Table (Datasheet View) In this view you can add new records, delete edit or existing records a b c d e Page 16 of 83 a) Moves to the FIRST record. b) Moves to the PREVIOUS record. c) Moves to the NEXT record. d) Moves to the LAST record. e) Creates a NEW record. 2.03 Creating relationships between tables A relationship determines how to link information from many tables so that Microsoft Access can determine knows how to relate the information. A join compares the values of a field in one table with the values in the joined field of the other table. The result is a link of the records in both tables wherever the values of the joined fields equal. When it finds matches it combines those two records and displays them as one record in the query’s results. If one table does not have a matching record in the other table, neither record appears in the query’s results. NB The fields used to join two tables must be of the same data. The joins created during the query apply only for that query. In some instances, Access automatically creates joins e.g. If you add two tables to a query and the tables each have a field with the same name and data type and a relationship has already been created between the tables; If one of the join fields is a primary key. If Members No. in the Members table was a primary key, then a join would have automatically been created between the members and have automatically been created between the Members and Rental tables. Primary keys are usually shown in boldface. After setting up tables to store related information, you need a way of linking the details in the different tables. Those tables should be already normalized. Procedure 1. You cannot create or modify relationships between open tables, Close any open tables. 2. From the Toolbar click on the relationships icon Relationships Page 17 of 83 OR From the Menu Bar Choose “Relationships” from the ‘Tools’ menu 3. If the tables you want to relate are not displayed, choose ‘Show Table’ option from the “Relationships” menu. 4. Select the required tables then click on the button ‘Add’. Resize the table window if necessary so that you can be able to see all the fields in it. 5. Drag the field that you want to use to establish the relationship from one table to the related field in the other table. In the above example drag ‘CategoryID’ from the ‘Categories’ table to CategoryID’ in the ‘Products’ table] 6. When you release the mouse the following dialog box appears: Page 18 of 83 In the dialog box you confirm that the field use to establish the relationship is correct on both tables. Types of relationships One to One This is where one record in One Table can have only one related record in another table. For example a Man Can have Only One Wife One to Many This occurs where one record in a Table (Parent Table) can have many related records in another table (Child Table). Page 19 of 83 Many to Many One record in either Table A or Table B can relate to many records in other table. For example, suppliers can supply many products, and products can be supplied by many suppliers. NB: If the relationship exists between two linked tables, the termed as External the the relationship is Microsoft Access checks the data available in the tables and suggests the type of relationship that would be suitable. 7. To change the relationship created without exiting, click Create New. 8. Enter the details of the relationship as shown above then Click OK 9. Otherwise click on Create. 10. The relationship is indicated by the join line between the two tables 11. Save and close the relationships so that next time the database is opened relationship will not have to be created afresh. Referential Integrity Page 20 of 83 the Referential integrity is a system of rules that Microsoft Access uses to ensure that relationships between records in related tables are valid and that you don't accidentally delete or change related data. Once referential integrity is enforced then: You can't enter a value in the foreign key field of the related table that doesn't exist in the primary key of the primary table. You can't delete a record from a primary table if matching records exist in a related table. For example, you can't delete a category record from the categories table if there are products assigned to the category in the products table. You can't change a primary key value in the primary table, if that record has related records. For example, you can't change the CategoryID in the categories table if there are Products assigned to that Category in the Products table. Editing Relationships between tables Deleting Relationships 1. Click on the Relationship line for the relationship you want to delete (The line will turn bold when it is selected). 2. Press the Delete key on the keyboard. 3. Confirm that you want to delete the relationship. 4. Click Yes Modify Existing Relationships 1. Double-click the relationship line for the relationship you want to edit. Set the new relationship options. 2.04 Adding Records You can add records in a table only when you are in the Datasheet View. It is not possible to add data in an ‘AutoNumber’ field. Move to the blank record showing on your table and enter your data, as shown below Page 21 of 83 You may find it easier to add a record after clicking the new ‘button’ ( ) 1.05 Deleting Data in a Record. Access allows you to EDIT or even DELETE the contents of a record. To delete or edit 1. Highlight the text (e.g Maithya as listed above) 2. Press the Delete key OR Type the new text you would like to replace with NB. If you delete or Edit by mistake you may use the UNDO command from the Edit menu or the undo icon ( ), However a full RECORD deletion cannot be reversed. Page 22 of 83 To delete the entire table, a) Determine that the table contains data that you do not require any more. b) Ensure that the table is not open either for Design or data entry. c) Highlight the table you want to delete then press the ‘Delete’ key answer ‘Yes’ to the question below 2.06 Changing the width of a column/Moving a column. This is usually done to enable the user to view all data in a particular column. The column may contain data that is not entirely visible due to its length e.g. the ‘Title’ field below has been expanded To Expand: Move the mouse pointer to the point at the end of the field name (Title) and at the beginning of the next field name. The mouse pointer changes to a Thick Cross. Press the left mouse button and drag in towards the right. To move the column Move the mouse pointer to the top of the column, on the field name so that it changes to a thick arrow pointing downwards. Click once to highlight Press and hold the mouse pointer on the field name then drag to the desired position NB: This does not change the position of the field in design view Page 23 of 83 2.07 Finding Records You may sometimes need to find records in your table, for example you may require to change the salary of one of your employees say “Suyama” To Find a record: f) Open the table in ‘datasheet’ view g) Move to the field on which you would like to perform the search e.g. ‘Last Name’ h) From the ‘Edit’ menu choose ‘Find’ i) The following Dialog Comes up j) Type the name that you want to search in the ‘Find What’ list box k) Click on the ‘Find Next’ button l) If this is not the record you are looking for, click on ‘Find Next’ Find dialog box Options: a) Match Click on the drop-down arrow to display a list of search locations Page 24 of 83 b) Any Part Of The Field Searches for any occurrence of the text string. For Example, searching for ‘Smith’ finds ‘SmithSonia’ and ‘JohnSmith’ c) Whole Field Recognise a match only when the text string matches the complete contents of the field. d) Start of Field Searches for the text string at the beginning of a field for example searching for ‘Smith’ finds ‘SmithSonia’ not ‘JohnSmith’ e) Search Click the drop-down arrow to display a list of search directions. f) All Searches through all records in the database g) Up/Down Searches either downwards or upwards from the current position 2.08 Deleting records Occasionally, you will need to delete unwanted records from your file eg those of customers who are no longer shopping with us. a) Open the table in Datasheet View b) Highlight the record to be deleted as shown below c) Press the ‘Delete’ key d) When you are prompted as shown below, choose ‘Yes’ Page 25 of 83 e) The selected record will be deleted permanently. 2.09 Filtering and Sorting Records Filtering Filtering allows you to view a set of records depending on some criteria that you may set Steps: 4. Select “Filter” From the “Records” menu then select “Advanced Filter/Sort”. The filter window appears as shown below: 5. Choose the field(s) by which you want to apply the filter by clicking on the Combo Box button (shown at the point where the cursor is). These fields will also be displayed. 6. You may optionally choose a sort order (Ascending or Descending) 7. Type in a criteria to be used, then “Right Click” and choose the “Apply Filter” option Page 26 of 83 8. To redisplay the entire table, click on the “Remove Filter” ( “Records” menu, choose “Remove Filter/Sort” ) button or from the 2.10 Sorting You may sometimes require to arrange records in some order e.g. you may arrange them according to the “LastName”. This may be useful in determining the highest or lowest value in the table. Steps: 1. Position the cursor in the field on which you want to sort. E.g. to sort by the lastName, position the cursor in the lastName field 2. To sort in ascending order (Smallet to Largest) click on the ( ) Sort ascending button To sort in ascending order (Largest to Smallet) click on the ( ) Sort descending button Page 27 of 83 Exercise 1. Create a database called Travellers 2. Create the following tables in the database. (Primary Keys are Underlined) 3. Set any other properties that you want for your field for data automation. a) Drivers Fields Data type Drivers_ID Number FirstName Text LastName Text Address Text Date_Of_Birth Datetime Hire_Date Date/Time Salary Currency b) Vehicles Fields Data type Vehicle_ID Number Reg_No Text Capacity Number Make Text Page 28 of 83 Type Text Date_Acquired Date/Time c) Shifts Fields Data type Shifts_ID Number Drivers_ID Number Vehicle_ID Number Route_No Text Shift_Name Text Page 29 of 83 d) Routes Fields Data type Route_No Text Distance Integer Fare Currency Destination Text 4. Define the appropriate relationships for your tables. Enter The Information below in your tables already designed Table: Drivers Drivers are paid a uniform salary of Sh. 12000/-. Update your table to reflect these details. Table: Routes Page 30 of 83 Table: Vehicles Table: Shifts Drivers are assigned the following shifts schedules. Add this information in the Shifts table. Page 31 of 83 Lesson 3 3.0 Introduction to Queries WHAT THEY ARE AND HOW THEY WORK Queries are used to view, change and analyse data in different ways. They can also be used as the source of records for forms and reports. Why use queries? We need queries when we want to ask ourselves questions about data stored in our tables. How do they help us? In choosing fields Choosing records that meet a certain criteria In sorting records Performing calculations - can create calculated fields and add data to them. 3.1 Creating/Saving Queries Open your database Select Query option Double Click Create Query In Design View Page 32 of 83 A list similar to the one shown below will appear. Select table to query from list, Add, then Close This gives QBE (Query By Example) display. Select fields you need and drag them to QBE Add a criteria to be used in selecting records (if desired) as shown below If required, choose a sort order in the ‘Sort’ row. To do this, you must determine which row(s) will be used for sorting e.g. you may use the ‘FirstName’ field and sort it ascending i.e. names beginning with ‘A’ then ‘B’ then ‘C’ and so on till ‘Z’ Page 33 of 83 Save the query, then close it is important to use an Appropriate name to distinguish you queries later e.g “Employee Names” To run the query, ‘Double Click’ on it OR if the Query window is open Click on the ‘Run’ icon ( ) NB. You may choose not to display some fields by removing the ‘Tick’ under the ‘Show’ row e.g. The field ‘Title’ above will not be displayed A dynaset (Dynamic view of table) appears after opening the query table saved. 3.2 Complex Queries Sometimes it is necessary to extract data from more than one table. This is always the case if your tables are properly constructed. For Example, you may have a ‘Product Categories’ Table as well as a ‘Products table’, every product belong to a particular category thus ‘Pork, Chicken, Mutton’ are All types of ‘Meat’ and ‘Cabbages, ‘Sukuma Wiki’ are types of ‘Vegetables’. If you needed to extract comprehensive ‘Products’ data then you would need to extract it from both tables. Page 34 of 83 3.3 Creating Complex Queries A query can be used to bring together data from more than one table and show the results in a single datasheet. Procedure 1. From the Database Window, select ‘Queries’. 2. Create query in Design view. 3. Choose all the tables that contain the information that you need to view in the query then click on Add. Page 35 of 83 4. Click on Close to get to the Design grid. 5. All the tables selected are shown in the Design grid. The table windows can be expanded so that all the fields can be seen. 6. In order to retrieve data from multiple tables, a join (link) needs to be created between the tables. A join I s a relationship established between the tables by the use of Join Lines. 7. Before creating any join lines, first establish which fields are common or have the same information between the tables. These fields must be of the same data type. From the example above, the field CategoryID in the Categories table is similar to the field CategoryID in the Products table. Page 36 of 83 8. To create a join line, drag the field that you want to use to establish the relationship from one table to the other table. For example, drag the field CategoryID in the Categories table to the field CategoryID in the Products table. NB. If you have already created relationships between your tables, then Microsoft access creates these joins in the query Grid automatically. 1. If you wish to view a filtered list then Type in the criteria. you may use a wildcard symbol i.e. the asterisk (*). We would like to get all the products whose name start with ‘M’ so we type in the criteria as Like "M" & "*" 2. Run the query to view its results. Save the query using an appropriate name. This kind of query may be used to produce a report. The resulting report will derive information from the query and therefore from all the tables used in the query. 3.4 To print the resulting data: 1. From the ‘File’ menu choose ‘Print’ 2. To print using ‘Default’ settings, click on ‘Print’ else change the desired options (No Of Copies, Pages) then ‘Print’ Page 37 of 83 3.5 Query Types Ms-Access supports various types of queries used to accomplish different functions. These will be introduced briefly and covered in more detail later. 1. SELECT QUERY This is a query where a user querying a database selects what to view by the use of a set criteria entered at the dynaset view. 2. UPDATE QUERY This query allows some fields within a table to be updated automatically. 3. MAKE TABLE QUERY This query allows for creation of a new table which can contain records sharing some properties e.g. A table for all production staff 4. DELETE QUERY This query allows deletion of records from a table, especially those that have been transferred to another table. 5. APPEND QUERY This query allows for joining of tables. These are tables, which may earlier have been separated. 6. CROSSTAB QUERY This type of query allows you to summarise data in a spreadsheet format. This may be by Month for a whole year. NB: To delete a query: Ensure that the query is not open in design or datasheet view Highlight it from the database window by clicking on it Press the ‘Delete’ key Confirm that you want to delete the query when prompted Deleting a query has no effect on the data stored in the table(s) upon which it is based. 3.6 Creating Total Queries Sometimes, you may want a query to summarize the information in a table without giving details on each record. Page 38 of 83 For example, as a shopkeeper you may want to find out the total number of each product you stock. You will need to create a query that groups this information accordingly and calculates the required totals. Procedure 1. In the Database window, create a new query in Design View and add the table to be used for the query. 2. Select the fields to appear in the query. Note that when creating a total query, you can select the same field more than once as in the example below. 3. In the Query window, click the Totals button, or choose Totals from the View menu. Page 39 of 83 4. The Total row appears in the grid. The words ‘Group by’ appear under each field selected in the Query. 5. When designing a total query, the fields to be used for grouping and the fields to be used for totals (calculations) need to be specified. For fields to be used for Grouping, select ‘Group by’ in the Total Row. For fields to be used for Totals, select a type of calculation e.g. Count, Sum or Average from the drop-down list in the Total row. (See the table below for Types of Totals possible) TYPES OF TOTALS Name Sum Avg Calculates: The total values in a field The average of values in a field Count Max StDev Min Var First Last The number of values in a field The highest value in a field. The std deviation of values in a field The lowest value in a field The variance of values in a field The field value from the first record in a table or query The field value from the last record in a table or query. 6. Run the query to view the results. 7. As shown above, Microsoft Access displays headings that reflect the type of calculation that has been performed to get the shown numbers e.g. CountOfSubject, AvgOfUnitPrice, MaxOfSalary, CountOfNo etc. Page 40 of 83 Exercise 1. Create database Q1with the following tables and implement the accompanying conditions. name owner species sex birth death Fluffy Harold cat f 1993-02-04 Claws Gwen cat m 1994-03-17 Buffy Harold dog f 1989-05-13 Fang Benny dog m 1990-08-27 Bowser Diane dog m 1989-08-31 Chirpy Gwen bird f 1998-09-11 Whistler Gwen bird Slim 1995-07-29 1997-12-09 Benny snake m 1996-04-29 a. The table should not allow a user to enter a date of birth that is earlier than the year 1980 b. Sort the data by the field “birth” in ascending order c. Create a query that will show us only the following species of animals: dogs only cats only all the male dogs all the female animals all animals whose owner is Harold all animals whose owner is Gwen all animals whose owner is either Benny or Harold Page 41 of 83 Lesson 4: Forms FEATURES OF A FORM 1. CONTROL These are elements that hold information in forms. A control has two parts: Label and control field E.g. SURNAME MR. MUSAU Label Control field (The name is picked from a table or a query) 2. UNBOUND CONTROLS These are controls that are not linked to any table i.e. controls, which are not dragged, from a table or a query. 4.01 creating forms using the form wizard Ms Access has a form wizard which asks you questions about the form you want to create, then creates a form based on your responses. STEPS 1. In the Database window, click the Form button, and then choose the New button 2. In the Select A Table/Query box, type the name of the form’s source table or query, or select one from the list. 3. Choose the Form Wizards button 4. Answer the questions in the Form Wizards dialog boxes. From the last dialog box, you can display the form in Design view or Form view. NOTE: If the Form Wizard doesn’t create the exact form you want, you can change the form yourself in design view, or you can use the Form Wizard again and choose different option as you answer the questions. 4.02 creating forms using auto form 1. In the database window, select the table or query for which you want to create a form. 2. Click the ‘New Object’ button and then select ‘Autoform’ from the dropdown list (AS SHOWN). Page 42 of 83 A new form is created based on the selected table or query. You can edit the controls in this form just as if it was a form created without using the Autoform as explained below 4.03 creating a form using design view While using a Form Wizard is the easiest way to create a form, it may not offer the design you need. If you want to design a form yourself, create a blank form, and then add the controls and other design features you require. 1. In the Database window, click the Form button, and then choose the New button. The new form dialog box appears. 2. In the Select A Table/Query box, type the name of the form’s source table or query, or select one from the list. (To create an Unbound form, leave this box empty). Page 43 of 83 3. Click ‘Ok’. A new blank form is shown as indicated below. 4. Drag the fields that you would like to see in the form arrange and edit them as appropriate using the properties window which is activated/deactivated by clicking on the shown. icon as Caption Box 5. To adjust the size of a control, click on it and use the fill handles to adjust it. This is done by achieving the double headed arrow by positioning the mouse over any one of the ‘Fill Handles’, clicking and holding the left mouse button then dragging inwards or outwards as required. Page 44 of 83 NB. You may also use the ‘Properties box’ to set other properties e.g. Change the colour display by changing the entry in the ‘Fore Color’ text box. Fill Handles 6. Save the form using an appropriate name 4.05 opening a data entry form Once the form has been created, you may open it for data entry. You may do this by double clicking on it in the database widow OR 1. Click on the form to highlight it. 2. Click on the ‘Open’ button in the database window Open button 4.06 customising a form CREATING A CONTROL As you design a form or a report, you place controls on it. The controls you create in design view are the title, fields and pictures you see in form view. 1. From the menu bar select ‘View’ option, then ‘field list’ (in case it is not active) Page 45 of 83 Field List 2. Drag the required fields from the list to the form, where they appear both the label and the control field. By clicking inside the label, the user can delete and type a label of choice. NB All the fields can be dragged at once to the form by double clicking the headings of the field lists and all the fields will be shaded blue. Point and drag them at once. POSITIONING THE CONTROLS Click to select the control to move, and then move the control by use of mouse pointers with the following shapes: One finger: moves one part at a time Five fingers: moves both the label and the control field Re-sizing can be done by pointing and dragging the dark spots. DELETING A CONTROL Click on the control to select it and then press the delete key 4.07 Object Linking and Embedding (Ole) LINKING When you link an OLE object, the object is stored in a separate file but it is displayed in your form or report. Linking is used when one requires an OLE object to change when the data in the source file changes Page 46 of 83 EMBEDDING When you embed an OLE object from another application, the object becomes part of your database. When you want to edit the object, you open the application used to create it, make changes to the embedded picture, and then return to your form window. The original file remains unchanged. EDITING OLE OBJECTS After you embed an OLE object, you open the source application by double clicking the relevant field in form view and then make changes. Ole Object 4.08 Creating Unbound Controls These are fields added to the form in design stage. A toolbox is activated from the “View” menu which provides two useful icons for this purpose: Page 47 of 83 Aa This tool allows the entry of both the label and control fields. Ab| Allows entry of labels only e.g. When typing headings. To create an Unbound control, you click the Ab| tool then mark the area to place the control by dragging across the form. The label will bear a general name Text ... and the control unbound 4.09 Calculated Unbound Controls This is a field added to the form created based on data of other fields dragged from a table/query. 1. Create an unbound control on the form 2. Select the unbound field and type an expression E.g. To create a new field for Total Products Value: CREATING A COMBO BOX In many cases you will find it easier to choose an item from a list when editing or entering new records into your table. A combo box helps to choose from such a list. The drop down list may be extract from: a) A Table/Query b) A field list c) A value list Example Page 48 of 83 Procedure 1. Create a table to contain the list of items to appear in the combo box. This Table is the Row Source. 2. Select the table in which data from a Combo box will be inserted. In its design view, add a new field to contain the data selected from a combo box. (In case it is missing). This field is the Control Source. 3. Select the form based on the above-mentioned table, view it in Design State. 4. Disable the control wizard tool icon and then click the combo box button (Which turns grey and suppressed). Control Wizard 5. From the field list, drag the field added in two (2) above to the form. 6. Check its properties and on the option row source, type the name of the table that contains the data for your combo box. 7. Save the form and open it to make your entries. NOTE To limit selection to only what is available in the combo box, set the property of Limit to list of the combo box to Yes. Page 49 of 83 CREATING A LIST BOX A list box is a variation of the combo box where the values are displayed in a list rather than a dropdown list. Scroll bars are added to enable the use to choose any item from the list 1. Create a table to contain the list of items to appear in the list box. This table is the Row source. 2. Select the table in which data from a list box will be inserted. In its design view, add a new 3. 4. 5. 6. 7. field to contain the data selected from a list box. (In case it is missing). This field is the Control Source. Select the form based on the above mentioned table, view it in design state. Disable the control wizard tool icon and then click the list box button (Which turns grey and suppressed). From the field list, drag the field added in two (2) above to the form. Check its properties and on the option row source, type the name of the table that contains the data for your list box. Save the form and open it to make your entries. NOTE 1. A list box shows a Up and Down arrow used for scrolling while searching for an entry. A list box thus wastes space while a combo box opens up only when clicked. 2. Both the combo and list boxes can be used to display a different piece of data than what is actually saved in the table E.g. You may be making use of CategoryIDs instead of CategoryNames when saving data in the table as shown below (This will always be the case when your tables are properly normalised) Page 50 of 83 In the example above, Chai (The First Product) belongs to the Beverages category. On the data entry form, if we wish to display the “Category Name” and not the “Category ID” then we will in addition tio the steps listed above: 1) Invoke the Query Builder alongside the “CategoryID” Combo box. Page 51 of 83 2) Construct a query as shown below 3) On closing answer “Yes” when prompted 4) Set the “Bound Column” property of the control as shown above to 2. 5) Save and open your table in datasheet view. Page 52 of 83 4.09 Data Protection From the Form properties, the user is able to control and maintain data security. One can set an undelete form by indicating No to Allow deletions. This will ensure no values are deleted while using the form. Forms can also be locked by setting Allow edits to NO and Record locks to All Records. Once the form is locked, no changes can be made to a field. CONCATENATION This is the process of combining fields from a table into an Unbound control within a form. E.g. If in a table we have two fields representing surname (SNAME) and first name (FNAME) respectively and there is need to combine the two fields in the form so that the two names appear together. An Unbound control tool will be used and the following formula used to concatenate the fields. FULLNAME =[SNAME]& “ Label 4.10 “&[FNAME] Concatenated fields Editing Data in a Form FINDING RECORDS It is possible to find records in a form just as it is in tables as explained in 1.6. To find records: 1. Open the form 2. Move to the field in which you want to search (e.g First Name.) 3. From the ‘Edit’ menu choose ‘Find’ then follow the instructions in 1.6 DELETING A DATA ENTRY FORM To delete a data entry form: 1. Click on the form to highlight it 2. Press the ‘Delete’ key. 3. When promoted answer ‘YES’ NB: Even though forms are based on an underlying ‘Table’ or ‘Query’, deleting the form does not have any effect on the data. PRINT A DATASHEET a) Open the form which contains the data that you would like to print b) From the file menu choose “Print” To print all records, click ‘OK’ c) You may preview by choosing “Print Preview” i.e. Page 53 of 83 FILTER BY FORM To filter by form: a) Open the form in ‘Datasheet’ View b) From ‘Records’ choose ‘Filter’ then ‘Filter By Form’ c) Move to the field that you would like to filter by e.g. Category combo box appears to the right, you may use this combo box to choose the data to filter OR you may type the data directly d) From ‘Records’ choose ‘Filter’ then ‘Apply Filter/Sort’. All filtered data will show in the form e) Remove the filter trough ‘Records’ ‘Filter’ then ‘Remove Filter/Sort’ Exercise 1. Create a table and a form based on the following data. NAME STAFF OVER-TIME PAY AMOUNT Angeline Masumbuko 8500 Ajit Kumar 12500 Edward Kabarega 6500 2. Within the form, create a calculated Unbound control field to hold the tax deducted which is 10% of the amount paid. Page 54 of 83 Exercise NAME James K Leila A Peter M. TOWN Accra Nairobi Mombasa DEPARTMENT DEPARTMENT Finance Administration Using the above data, create two tables. Following the instructions given earlier, create a combo box to input department details to be part of the first table. Page 55 of 83 Lesson 5: Reports REPORTS This is information that is organised and formatted to fit your own specifications e.g. mailing labels, Invoices, Sell Summary and Phone lists. 1. Reports are an effective way for presenting information to be distributed in a printed format. You can control the size and appearance of everything on a report, e.g. by formatting the font style and size. 2. Pictures and graphs can be incorporated into the report to make the report more meaningful. 3. Data can be organized and grouped into categories with sub-totals, making it easier to read. For example, in a list of product sales, you can group records by products and get sub-totals for each to see what product sold the most. In addition, calculations can be performed on the data. For example, you can calculate totals for a field such as Total Sales. 5.01 creating using A Wizard 1. In the Database window, select the Reports tab. 2. The New Report dialog box appears. From the options in the “new report” dialog box, select Report Wizard. 3. Choose the table that contains the data you want to base your report on and then click OK. Page 56 of 83 The table below describes what each option in the New Report dialog box does. Option Design View Report Wizard AutoReport:Columnar AutoReport : Tabular Chart Wizard Label Wizard Description Used to create a report without using a wizard. Automatically creates a report based on the fields selected. Creates a single column report i.e. the records are displayed in a single column. Creates a tabular report i.e. each record is displayed from left to right across a report (as a row of fields). Creates a report with a chart. Creates a report that has been formatted for printing on mailing labels. Note: The Report Wizard contains a series of steps to be followed when creating a report. 4. Select the fields to appear on your report from the list of available fields. This allows you to choose only the fields that you require in the report. Click on “Next”. Page 57 of 83 5. Select the fields for grouping if required. Grouping data within a report means arranging the data by a certain field so that all the records related to that field are displayed in one group. In the example below, the data is to be grouped by the CategoryID field. 6. Select the fields to sort by and specify the sort order i.e. ascending or descending. You can sort on up to four fields (levels) in the report. Page 58 of 83 7. You may choose to summarise your report by adding other options by clicking on the “Summary Options” button 8. Choose a layout for your report. You can also change the page orientation for the report to landscape if you have many fields. Page 59 of 83 9. Select the look or style you would like for the report. There are different looks to choose from like corporate, formal or soft gray. 10. Type in the title for the report and then click on Finish. Page 60 of 83 11. After a few seconds, the Report is generated in Print Preview. Page 61 of 83 5.02 Creating Using Design View Steps 1. From the Report Tab, click on New, then choose the table or query to be based on the report then choose design view. 2. Drag the required fields from the field list into the Report details. If the field list is not visible, active it by clicking on “View” then “Field List”. If you want the fields to be appearing on top of each of the Pages, then drag the fields and drop them on the report Header. NOTE We can also use calculated or expressions in the reports Examples =now() =(page) =[Field1]& “ “ &[Field2] =[Field]*0.1 : Will display the date and time : Will number the pages :Will combine two fields. :Will display a calculated field so long as the To add these fields: 1. From the “Insert” menu choose the desired option as shown below Page 62 of 83 field is numeric. Choose the desired style i.e. Using Expressions in Reports We can use expressions to perform arithmetic on fields, Sum a group of records and combine two or more text fields. Combining text fields 1. Create an Unbound control 2. Then inside the control type =[Field1]& “ “&[Field2] e.g. =[FNAME]& “ “ &[SNAME] Arithmetic 1. Create an Unbound control 2. Then inside the control type =[Field1]*[Field2] i.e. To calculate house allowance which is 15% of Salary we type =[Salary]*0.15 Summing a group of fields/Records We use this information to add a group of fields i.e. If we want to sum together a group of fields which are similar in difference records. For example, If we want to sum all “Units On Order” for a particular supplier, we would include the expression “=Sum ([UnitsInStock])” in the “Supplier Group footer”. Page 63 of 83 To achieve this 1. Create Unbound control on the report footer or group footer 2. Type =sum([UnitsInStock]) Results 5.03 Sections of the Report Report Header. This section has the main header or title for the report. It is printed once at the beginning of the report. Page Header This section contains information to be printed at the top of each page of the report. This may include information like date or column titles. Group header This section contains information that is printed at the beginning of each record in the table. This section is present only when there is grouped data in the report. The name given to this section depends on the grouping field. In the example above, the report is grouped on Subject and hence the name ‘Subject Header’. Detail This section contains information that is printed for each record in the table i.e. the main area of the report that contains the actual records. Page 64 of 83 Group Footer Similar to group header but this section contains information that is to be printed at the end of each grouping of data. A good example of this is sub-totals. Page Footer This section contains information that is to be printed at the bottom of each page e.g. page totals, page numbers etc. Report Footer Just like the report header, this section contains information that is printed once at the end of the report like Grand Totals etc. 5.04 Previewing and printing your report This is important when: 1. You want to see or view how the report will look like when it is printed. 2. Whenever you need a paper copy of the report to present to other people and for filing. Double click on the report that you would like to view OR choose the “preview” option in the database window. To preview two Pages Suppose you want to view only two pages of the report, click on the two pages Button on the toolbars. Two Pages To view more than two pages, then: Page 65 of 83 1. From the ‘View’ menu choose the option ‘Pages.’ 2. Select the number of pages you want to display To Exit from Print Preview. Click on the Close button. When you exit from Print Preview, you can view the report in Design View. Page 66 of 83 Creating Reports from Queries If you require information is needed from many tables, the best method is to create a query that incorporates all the required tables and then create a report from the query. Procedure 1. In the Database Window, select the Reports Tab and click on New. 2. Select the query to be used for the report. 3. Select the fields you want to use from the query. 4. Complete the remaining steps in Report Wizard and preview the report. Page 67 of 83 3. 5.05 Reports Based In Multiple Tables. When you want to obtain information from more than one table for example you may want to know who works in which department, which floor and when they were employed. This cannot be obtained from the tables independently hence we need both to provide this information. Page 68 of 83 Procedure 1. Create relationships between the tables as appropriate. 2. From the database window choose ‘Reports’ and then click on ‘New’. Choose the ‘Report Wizard’ option. Choose a table on which to base your report then Click ‘OK’. 3. In the next step choose tables and then the fields from those tables that are required. 8. Determine how the information is going to be grouped then Click on Next to proceed. 9. Complete the remaining steps and preview the report. Page 69 of 83 10. To change orientation Open the report in either design or datasheet view From the ‘file’ menu, choose ‘Page setup’ The following dialog appears Switch between portrait and landscape as desired. Page 70 of 83 5.06 To print the report From the ‘file’ menu choose print To print using default settings click on ‘OK’ else change the settings then print Exercise 1. Create the following table and save it using a suitable name. 2. Then create a report based on the table. 3. Let the report have the following: Grand Totals for all the persons Sub Total for the Department Date and time, and Page Number on the Page footer 4. Let also the report have the Full Names on one control. 5. Save the report under a good name 6. From the same table, create a parameter query and save it. 7. Create a separate report based on this parameter query. 8. Create an Unbound control for Tax which is 15% of Salary. FNAME SNAME DEPARTMENT SEX SALARY Jones Jane Loise David Charles George Titus Ester Thomas Ken Denis Walter Challa Michael Emma Tonny Computer Production Sales Computer Sales Computer Production Sales Male Female Female Male Male Male Female Female 4000.00 5000.00 4500.00 6200.00 8900.00 6000.00 6400.00 4200.00 Page 71 of 83 Ms Access Project Table: Categories Columns Name Type Size CategoryID CategoryName Description Picture Long Integer Text Memo OLE Object 4 15 - Relationships CategoriesProducts Categories CategoryID 1 Products CategoryID Attributes: Enforced RelationshipType: One-To-Many Table: Customers Columns Name Type Size CustomerID CompanyName ContactName ContactTitle Address City Region PostalCode Country Phone Fax Text Text Text Text Text Text Text Text Text Text Text 5 40 30 30 60 15 15 10 15 24 24 Relationships CustomersOrders Customers Orders CustomerID 1 CustomerID Attributes: Enforced, Cascade Updates RelationshipType: One-To-Many Page 72 of 83 Table: Employees Columns Name Type Size EmployeeID LastName FirstName Title TitleOfCourtesy BirthDate HireDate Address City Region PostalCode Country HomePhone Extension Photo Notes ReportsTo Long Integer Text Text Text Text Date/Time Date/Time Text Text Text Text Text Text Text OLE Object Memo Long Integer 4 20 10 30 25 8 8 60 15 15 10 15 24 4 4 Relationships EmployeesOrders Employees EmployeeID Orders 1 Attributes: RelationshipType: EmployeeID Enforced One-To-Many Table: Order Details Columns Name Type OrderID ProductID UnitPrice Quantity Discount Long Integer Long Integer Currency Integer Single Page 73 of 83 Size 4 4 8 2 4 Relationships OrdersOrder Details Orders OrderID Order Details 1 Attributes: RelationshipType: OrderID Enforced, Cascade Deletes One-To-Many ProductsOrder Details Products ProductID Order Details 1 Attributes: RelationshipType: ProductID Enforced One-To-Many Table: Orders Columns Name Type Size OrderID CustomerID EmployeeID OrderDate RequiredDate ShippedDate ShipVia Freight ShipName ShipAddress ShipCity ShipRegion ShipPostalCode ShipCountry Long Integer Text Long Integer Date/Time Date/Time Date/Time Long Integer Currency Text Text Text Text Text Text 4 5 4 8 8 8 4 8 40 60 15 15 10 15 Page 74 of 83 Relationships CustomersOrders Customers Orders CustomerID 1 CustomerID Attributes: RelationshipType: Enforced, Cascade Updates One-To-Many EmployeesOrders Employees Orders EmployeeID 1 Attributes: RelationshipType: EmployeeID Enforced One-To-Many OrdersOrder Details Orders Order Details OrderID 1 Attributes: RelationshipType: OrderID Enforced, Cascade Deletes One-To-Many ShippersOrders Shippers ShipperID Orders 1 Attributes: RelationshipType: ShipVia Enforced One-To-Many Page 75 of 83 Table: Products Columns Name ProductID ProductName SupplierID CategoryID QuantityPerUnit UnitPrice UnitsInStock UnitsOnOrder ReorderLevel Discontinued Type Long Integer Text Long Integer Long Integer Text Currency Integer Integer Integer Yes/No Relationships CategoriesProducts Categories CategoryID 1 Attributes: RelationshipType: Products CategoryID Enforced One-To-Many ProductsOrder Details Products ProductID 1 Attributes: RelationshipType: Order Details ProductID Enforced One-To-Many SuppliersProducts Suppliers SupplierID Attributes: RelationshipType: 1 Products SupplierID Enforced One-To-Many Page 76 of 83 Size 4 40 4 4 20 8 2 2 2 1 Table: Shippers Columns Name ShipperID CompanyName Phone Type Long Integer Text Text Size 4 40 24 Relationships ShippersOrders Shippers ShipperID 1 Attributes: RelationshipType: Orders ShipVia Enforced One-To-Many Table: Suppliers Columns Name Type Size SupplierID CompanyName ContactName ContactTitle Address City Region PostalCode Country Phone Fax Long Integer Text Text Text Text Text Text Text Text Text Text 4 40 30 30 60 15 15 10 15 24 24 Relationships SuppliersProducts Suppliers SupplierID Attributes: RelationshipType: Products 1 SupplierID Enforced One-To-Many Page 77 of 83 Tasks 6.1 Tables 1) Create ALL the tables as listed above. DO NOT create the relationships until you are done with constructing the tables. 2) Create the relationships between the tables as specified above. 3) Enter data in the tables. Ensure that you follow the order: Categories, Shippers, Employees, Customers, Suppliers, Products, Orders and Order Details. Categories ID Category Name Description 1 Beverages Soft drinks, coffees, teas, beers, and ales 2 Condiments 3 Confections Sweet and savory sauces, relishes, spreads, and seasonings Desserts, candies, and sweet breads 4 Dairy Products Cheeses 5 Grains/Cereals Breads, crackers, pasta, and cereal 6 Meat/Poultry Prepared meats 7 Produce Dried fruit and bean curd 8 Seafood Seaweed and fish Page 78 of 83 Picture Employees ID Last Name 1 Davolio 2 3 4 5 First Name Title Title Nancy Sales Representative Fuller Andrew Vice President, Sales Leverling Janet Sales Representative Peacock Margare Sales t Representative Buchanan Steven Sales Manager 6 Suyama Michael Sales Representative 7 King Robert Sales Representative 8 Callahan Laura Inside Sales Coordinator 9 Dodsworth Anne Sales Representative Ms. Dr. Ms. Mrs. Mr. Mr. Mr. Ms. Ms. Birth Date Hire Date Address 08-Dec-48 01-May-92 507 - 20th Ave. E. Apt. 2A 19-Feb-52 14-Aug-92 908 W. Capital Way 30-Aug-63 01-Apr-92 722 Moss Bay Blvd. 19-Sep-37 03-May-93 4110 Old Redmond Rd. 04-Mar-55 17-Oct-93 14 Garrett Hill 02-Jul-63 17-Oct-93 Coventry House Miner Rd. 29-May-60 02-Jan-94 Edgeham Hollow Winchester Way 09-Jan-58 05-Mar-94 4726 - 11th Ave. N.E. 27-Jan-66 15-Nov-94 7 Houndstooth Rd. City Region Postal Code Country Seattle WA 98122 USA Tacoma WA 98401 USA Kirkland WA 98033 USA Redmon d London WA 98052 USA SW1 8JR UK London EC2 7JR UK London RG1 9SP UK Seattle WA London 98105 USA WG2 7LT UK Home Phone (206) 555-9857 (206) 555-9482 (206) 555-3412 (206) 555-8122 (71) 5554848 (71) 5557773 (71) 5555598 (206) 555-1189 (71) 5554444 Ext. 5467 3457 3355 5176 3453 428 465 2344 452 Notes Education includes a BA in psychology Andrew received his BTS commercial in 1974 Janet has a BS degree in chemistry Margaret holds a BA in English literature Steven Buchanan graduated from St. Andrews University Michael is a graduate of Sussex University Robert King served in the Peace Corps Laura received a BA in psychology Anne has a BA degree in English Suppliers ID Company Name Contact Name Contact Title Address City 1 Exotic Liquids Charlotte Cooper Purchasing Manager 49 Gilbert St. London 2 New Orleans Cajun Delights 3 Grandma Kelly's Homestead 4 Tokyo Traders Shelley Burke Order Administrator P.O. Box 78934 Regina Murphy Sales Representative 707 Oxford Rd. New Orleans Ann Arbor Yoshi Nagase Marketing Manager Tokyo 5 Cooperativa de Quesos 'Las Cabras' 6 Mayumi's Antonio del Valle Export Administrator 9-8 Sekimai Musashino-shi Calle del Rosal 4 Osaka 7 Pavlova, Ltd. Ian Devling Mayumi Ohno LA 70117 USA (100) 555-4822 MI 48104 USA (313) 555-5735 100 Japan (03) 3555-5011 33007 Spain (98) 598 76 54 545 Japan (06) 431-7877 3058 Australia (03) 444-2343 Manchester M14 GSD UK (161) 555-4448 Göteborg S-345 67 Sweden 031-987 65 43 5442 Brazil (11) 555 4640 Oviedo 9 PB Knäckebröd AB Sales Agent Kaloadagatan 13 Marketing Manager Av. das Americanas 12.890 São Paulo Page 79 of 83 Phone (171) 555-2222 Sales Representative Customers Country UK 8 Specialty Biscuits, Ltd. Peter Wilson Lars Peterson Postal Code EC1 4SD 92 Setsuko Chuo-ku 74 Rose St. Moonie Ponds 29 King's Way 10 Refrescos Americanas Carlos Diaz LTDA Marketing Representative Marketing Manager Region Melbourne Asturias Victoria Rep orts To 2 2 2 2 5 5 2 5 Custom Company Name er ID ALFKI Alfreds Futterkiste Contact Name Maria Anders ANATR Ana Trujillo Emparedados Ana Trujillo y helados ANTON Antonio Moreno Taquería Antonio Moreno Contact Title Sales Representative Owner City Region Obere Str. 57 Berlin Avda. de la Constitución 2222 Mataderos 2312 México D.F. Postal Country Phone Code 12209 German 030-0074321 y 05021 Mexico (5) 555-4729 Fax 030-0076545 (5) 555-3745 México D.F. 05023 Mexico London BLAUS Hanna Moos Sales Forsterstr. 57 Representative Marketing Manager 24, place Kléber Mannheim WA1 1DP S-958 22 68306 UK BERGS Berglunds snabbköp Sales 120 Hanover Sq. Representative Christina Berglund Order Administrator Berguvsvägen 8 Strasbourg 67000 German 0621-08460 y France 88.60.15.31 Owner Madrid 28023 Spain (91) 555 22 82 (91) 555 91 99 91.24.45.40 AROUT Around the Horn Owner Address Thomas Hardy Blauer See Delikatessen BLONP Blondel père et fils BOLID Bólido Comidas preparadas BONAP Bon app' BOTTM Bottom-Dollar Markets Frédérique Citeaux Martín Sommer Luleå C/ Araquil, 67 (5) 555-3932 (171) 555(171) 555-6750 7788 Sweden 0921-12 34 65 0921-12 34 67 Laurence Lebihan Owner 12, rue des Bouchers Marseille 13008 France Elizabeth Lincoln 23 Tsawassen Blvd. T2F 8M4 Canada (604) 5554729 Accounting Manager Tsawassen BC 0621-08924 88.60.15.32 91.24.45.41 (604) 555-3745 Products ID Product Name Supplier 1 Chai 1 2 Chang 1 3 Aniseed Syrup 1 4 Chef Anton's Cajun Seasoning 5 Chef Anton's Gumbo Mix 6 Grandma's Boysenberry Spread 7 Uncle Bob's Organic Dried Pears 8 Northwoods Cranberry Sauce 9 Mishi Kobe Niku 10 Ikura Category Quantity Per Unit 1 10 boxes x 20 bags 1 24 - 12 oz bottles Unit Price $18.00 Units In Units On Stock Order 39 0 Reorder Discontinued Level 10 No $19.00 17 40 25 No $10.00 13 70 25 No 2 2 12 - 550 ml bottles 2 48 - 6 oz jars $22.00 53 0 0 No 2 2 36 boxes $21.35 0 0 0 Yes 3 2 12 - 8 oz jars $25.00 120 0 25 No 3 7 12 - 1 lb pkgs. $30.00 15 0 10 No 3 2 12 - 12 oz jars $40.00 6 0 0 No 4 6 18 - 500 g pkgs. $97.00 29 0 0 Yes 4 8 12 - 200 ml jars $31.00 31 0 0 No Page 80 of 83 Orders Order Customer Empl ID oyee Order Date Required Date Shipped Date Ship Via Freight Ship Name Ship Address Ship City Ship Region Ship Country France 10265 BLONP 2 25-Aug-94 22-Sep-94 12-Sep-94 1 Ksh 55.28 Blondel père et 24, place Klébe 10278 BERGS 8 12-Sep-94 10-Oct-94 16-Sep-94 2 Berguvsvägen 8 Luleå S-958 22 Sweden 10280 BERGS 2 14-Sep-94 12-Oct-94 13-Oct-94 1 Berguvsvägen 8 Luleå S-958 22 Sweden 10297 BLONP 5 05-Oct-94 16-Nov-94 11-Oct-94 2 Ksh 92.69 Berglunds snabb Ksh 8.98 Berglunds snabb Ksh 5.74 Blondel père et 24, place Klébe Strasbourg 67000 France 10308 ANATR 7 19-Oct-94 16-Nov-94 25-Oct-94 3 Ksh 1.61 Ana Trujillo Em Avda. de la Con México D.F. 05021 Mexico 10326 BOLID 4 10-Nov-94 08-Dec-94 14-Nov-94 2 Ksh 77.92 Bólido Comidas C/ Araquil, 67 Madrid 28023 Spain 10331 BONAP 9 16-Nov-94 28-Dec-94 21-Nov-94 1 Ksh 10.19 Bon app' 12, rue des Bou Marseille 13008 France 10340 BONAP 1 29-Nov-94 27-Dec-94 09-Dec-94 3 Ksh 166.31 Bon app' 12, rue des Bou Marseille 13008 France 10355 AROUT 6 16-Dec-94 13-Jan-95 21-Dec-94 1 Brook Farm Str Colchester CO7 6JX UK Ksh 41.95 Around the Horn Order Details Order ID Product Unit Price Quantity Discount 10265 1 $5,000.00 4 0% 10265 4 $4,000.00 3 0% 10278 6 $5,900.00 3 0% 10278 10 $5,600.00 5 0% 10280 7 $3,400.00 3 0% 10280 9 $5,000.00 2 0% 10297 4 $3,400.00 1 0% 10297 5 $7,800 .00 1 0% 10308 5 $7,000.00 4 0% 10308 6 $5,600.00 4 0% 10326 4 $17.60 24 0% 10326 8 $4,500.00 1 0% 10331 8 $2,200.00 2 0% 10331 9 $5,600.00 12 0% 10340 4 $5,000.00 1 0% Page 81 of 83 Strasbourg Ship Postal Code 67000 Essex 6.2 Queries 1) Construct queries to accomplish the following tasks a. From the Categories and products table show the following fields CategoryName, ProductName, Price – In a new field, compute the total value of each product i.e. UnitsInStock * UnitPrice b. Create a new field in the Products Table called “TotalValue” then make an Update query to update this field with the total value as described above. c. Select all products with the letter “P” anywhere in the Name. d. We would like to know the value of all products within a category (e.g. the value of all products uinder the category ‘Condiments’). Construct a query to group the products and sum up the total values. HINT use the concept in a) above 6.3 Forms 1) Using autoform, construct forms for all tables apart from the categories and products tables 2) Using the design view construct forms for the categories and products tables. 3) Add a new control (UNBOUND) to display the total value of each product on the form 4) Add 1 product of your choice in the products table using the Products Form. 5) Delete the Categories Form 6) Using ‘filter By Form’, filter for all products of Type ‘Condiments’ 7) Using ‘Find’ search for ‘Aniseed Syrup’. 6.4 Reports 1) Construct a report based on the Query in 6.2 1(a) grouping the data by ‘CategoryName’ using the report wizard 2) Modify the report above by: a. Changing the colour of all labels to a different colour. b. Adding a field to show a count of the records in each category i.e. (number the records) c. Adding a field to show the total value of the product under each category. Page 83 of 83