Solved

Ms Access Auto populating a field based on a value on a form

Posted on 2014-09-08
1
314 Views
Last Modified: 2014-09-18
I have several fields on a form:
Price = [user enters and it is added to a table]
Qty = 19 (user enters)
each price = $.0489 (user enters)

total price:  $9.291 (calculation on the form based on [qty]*[each price]

the user can enter a qty and a each price which would give them a total price.  How do I get the total price to populate in the Price field?  The price is populated with default values or the user can overwrite the default value)
0
Comment
Question by:deefel
1 Comment
 
LVL 35

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40310890
As long as you keep the UnitPrice and the quantity, there is no need to keep the ExtendedPrice.  It is far better practice to calculate it in the query.  Doing the calculation in the query will also automatically populate the ExtendedPrice field on the form.  
Select ..., UnitPrice, Quantity, UnitPrice * Quantity AS ExtendedPrice
From ...;

If you insist on doing this in the form (against expert advice) then you have to worry about when to do the calculation.  You either have to do it in both the AfterUpdate event of the UnitPrice and Quantity fields or you would do it in the BeforeUpdate event of the Form.

Me.txtExtendedPrice = Me.txtUnitPrice * Me.txtQuantity
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question