Database Reference
In-Depth Information
13
In the expression box, click
<<E x p r >>
to select it. In the
Expression Elements
list, in
the
Tables
area of the
GardenCompany07.accdb
list, click
Order Details
. Then in the
Expression Categories
list, double-click
Quantity
.
So far, we have entered an expression that calculates the total cost by multiplying
the price of an item by the quantity ordered. However, suppose the sale price is dis-
counted due to quantity or another factor. The discount, which is stored in the Order
Details table, is expressed as the percentage to deduct. But it is easier to compute
the percentage to be paid than it is to compute the discount and subtract it from the
total cost.
TIP
The Discount field values are displayed in the Order Details table as percentages,
but they are stored in the database as decimal numbers between 0 and 1. (For ex-
ample, a discount displayed as 10% is stored as 0.1). So if the discount is 10 percent,
the percentage to be paid is 1-Discount, or 0.9. In other words, the expression will
multiply the unit price by the quantity and then multiply that result by 0.9.
14
With the cursor to the left of the closing parenthesis in the expression box, enter
*(1-
. In the
Expression Categories
list, double-click
Discount
. Then enter
)
(closing
parenthesis).
The entire expression now appears in the expression box.