ACTIVITY – CREATING NEW CALCULATED FIELDS GOAL The goal of this practice is to learn how to calculate different expressions with the QBE pane facility in MS‐ACCESS software. SCENARIO You work as a database expert for NorthWind, a groceries reseller that is selling its products to different warehouses all over the world. Your goal is to define the set of expressions that will calculate the values that have been requested by the management staff. All the steps you are supposed to undertake are described below. For all assignments use the Northwind.mdb file. Fields in a query are not limited to the fields from the tables in your database. You can also create calculated fields to use in a query. For example, you can create a calculated field named Discount Amount that displays the result of multiplying the value of the Discount Percent times the Price. To create this calculated field, follow these steps: 1. Create a new query using the table (tables) you would like to use. 2. Select the you would like to have in resulting dynaset, 3. Click the first empty Field: cell. 4. Type the expression you would like to calculate. For example: Total value:[UnitPrice]*[UnitsInStock], where Total value is the name of new field, [UnitPrice] and [UnitsInStock] are the name of fields from Products table used in expression, and “*” is an operator. Notice that the general format for creating a calculated field is as follows: Calculated Field Name: Expression to build calculated field If you didn’t type the name for new field in Step 4 above, Expr1: precedes the calculation. For two reasons, a calculated field has a name (supplied either by the user or by an Access default). The name is needed as a label for the datasheet column, and the name is necessary for referencing the field in a form, a report, or another query. Hint: To see the entire contents of the field cell, you can either drag the field until it is all visible or you can press the Shift+F2 keys to open the Zoom Window. Other operators you can use in expressions are presented below. YOUR ASSIGNMENT Using the table Products: 1. Create a new field called Total Value which will calculate the total value of each product in the warehouse (Total Value = UnitPrice*UnitsInStock). 2. Create a new field called Tax which will calculate the tax based on total value of each product in the warehouse (Tax = 0.22*Total Value). 3. Create a new field that will increase the reorder level for each product by 23% and call it new reorder level. 4. Create a new field that will calculate 30% of UnitPrice for all discontinued products. Using the table Employees: 1. Create a new field that will calculate the number of years that each employee has been working for the firm and call it work experience. 2. Create a new field that will calculate the age of each employee. ACTIVITY – USING QUERY PARAMETERS GOAL The goal of this practice is to learn how to use the query parameters. SCENARIO You work as a database expert for NorthWind, a groceries reseller that is selling its products to different warehouses all over the world. Your goal is to define the set of basic queries that will include the parameters and because of that will prompt you for values you would like to search for. All the steps you are supposed to undertake are described below. For all queries use the file Northwind.mdb. How to use query parameters? So far you’ve been entering selection criteria directly in the Design grid of the Query window in Design view. However, you don’t have to decide at the time you design the query exactly what value you want Access to search for. Instead, you can include a parameter in the query, and Access will prompt you for the criteria each time the query runs. To include a parameter, you enter a name or a phrase enclosed in brackets ([ ]) in the Criteria row instead of entering a value. What you enclose in brackets becomes the name by which Access knows your parameter. Access displays this name in a dialog box when you run the query, so you should enter a phrase that accurately describes what you want. You can enter several parameters in a single query, so each parameter name must be unique as well as informative. In order to build a query to help out to find all data about customer with specific company name: Start a new query on Customers table in the Northwind.mdb database. Add all fields to QBE datasheet. Enter the name “Enter the name of the company” enclosed in brackets in CompanyName field. Run a query for the following names: Bon app', Bottom‐Dollar Markets and QUICK‐Stop. Figure. QBE datasheet with the one parameter query design. YOUR ASSIGNMENT Build the queries that will help out to find: The names of the employees working on specific job position. The addresses of the customers from specific country. All data about employees whose name begins with specific letter or couple of letters. The names of the customers whose orders dates are in specific range.