Performing calculations in forms / queries

M

Michael E

Hello,
I'm looking to design a system in Access and were wondering if anyone can
tell me how I could use queries to work out something such as wages to be
paid by timing number of hours staff have worked by what there wages are.
Also is there a way to do this automatically in tables and forms?
Thank you for any help received
Mike
 
6

'69 Camaro

Hi, Mike.
Also is there a way to do this automatically in tables and forms?

One may make the calculations in queries and forms, but it's usually not a
good idea to store calculated values in tables, because the data used for the
calculations can change, and the stored calculated value would need to be
changed, too -- only there's no automatic way to do this. It's a maintenance
nightmare.

It's best to calculate values "on the fly" in a query or in a form. In a
query, try:

SELECT EmpID, (HrsWorked * Rate) As Wages
FROM tblEarnings;

.. . . where EmpID is the employee ID, HrsWorked is the number of hours
worked for the employee, Rate is the rate of pay per hour, and tblEarnings is
the name of the table.

In a form that is bound to a query (or table), text boxes can be used to
display the calculated amount. Try:

Me!txtWages.Value = Me!txtHrsWorked.Value * Me!txtRate.Value

.. . . where txtWages is an unbound text box, txtHrsWorked is a text box
bound to a field containing the number of hours worked, and txtRate is a text
box bound to a field containing the employee's rate per hour.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Top