| Creating a Lookup with Microsoft Access Tables | | | | QuantityID StartPrice EndPrice Discount |
| 1. Create a new table and save it as tblProducts. | | | | 1 £0.00 |
| Create the following fields in this table: | | | | £9.99 £2 |
| Field Name Data Type | | | | 2 £10.00 |
| ProductID AutoNumber | | | | £19.99 £5 |
| ProductName Text | | | | 3 £20.00 |
| ProductPrice Currency | | | | £29.99 £8 |
| Set ProductID as the primary key | | | | 4 £30.00 |
| 2. Enter the following data into the tblProducts Table | | | | £39.99 £10 |
| Product ID Product Name ProductPrice | | | | 5 £40.00 |
| 1 | | | | £49.99 £12 |
| A £5.99 | | | | Now close the table |
| 2 | | | | 3. Nearly there now, all we have to do is create a |
| B | | | | query that includes both tables. Create a new query |
| £10.59 | | | | in design view adding both the tblProducts table and |
| 3 | | | | the tblDiscounts table to the query. |
| C | | | | Now add the following fields to the query grid: |
| £21.99 | | | | From the tblProducts table add: ProductName |
| 4 | | | | & ProductPrice |
| D | | | | From the tblDiscounts table add: Discount |
| £35.49 | | | | In the criteria row for the ProductPrice field type the |
| 5 | | | | following: |
| E | | | | Between [tblDiscounts].[StartPrice] And |
| £19.99 | | | | [tblDiscounts].[EndPrice] |
| That’s you first table done, you can now close it. | | | | Save the query as qryDiscountLookup. Now run the |
| The second table will contain information about | | | | query to see the appropriate discount displayed for |
| discounts. The discount amount is dependant on the | | | | each product. |
| price of the product. For example if the product cost | | | | You could calculate the new sale price if you liked. |
| under £10 you only get a £2 discount. If it’s | | | | To do this switch back to design view in your query |
| between £10 and £19.99 you get a whopping £5 | | | | and in the next available field in your query grid write |
| discount – too good to be true you might say! | | | | the following in the Field: row. |
| There are other discount available too. | | | | SalePrice: [ProductPrice]-[Discount] |
| Create a new table and save it as tblDiscounts. | | | | Before you run the query you had better format your |
| Create the following fields in this table: | | | | new calculated field to show the result in currency |
| Field Name Data Type | | | | format. To do this click into the field on the query grid |
| DiscountID AutoNumber | | | | then click View | Properties. In the Field properties |
| StartPrice Currency | | | | window find the Format properties and choose |
| EndPrice Currency | | | | Currency . Save and run query again. You should |
| Discount Currency | | | | have the discounted price for each product displayed |
| Set DiscountID as the primary key | | | | in your new SalePrice field. |
| Enter the following data into the tblDiscounts table: | | | | |