There's no point in manually calculating a field based on the value in another field. With this simple form trick, you can have Access perform the calculation automatically.
When a field needs to be calculated using data from another field, you don't have to perform the calculation yourself. You can create a form that automatically calculates the field for you. For example, after entering a product discount in a form, you want Access to update the discount price field automatically (Figure A).
Follow these steps:
- Open the form in Design View.
- Right-Click the Discount field.
- Click on the Event tab and click the Build button of AfterUpdate property box (Figure B).
- Enter the following code at the prompt (Figure C):
Private Sub Discount_AfterUpdate()
[Discount Price] = [UnitPrice] * (1 - [Discount])
- Press Alt + Q.
Now, when a discount is entered in the Discount field, the Discount Price field will automatically update with the new price.
Miss an Access tip?
Check out the Microsoft Access archive and catch up on other Access tips.
Help users increase productivity by automatically signing up for TechRepublic's free Microsoft Office Suite newsletter, featuring Word, Excel, and Access tips, delivered each Wednesday.