If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Calculated Fields on a Form
I have a form with two fields. One is called hours and the second is called
labor rate. I have a third field called Labor Cost. When a user enters this field, I would like it to default to Hours times Labor Rate. What is the best way to accomplish this? Thanks |
#2
|
|||
|
|||
Calculated Fields on a Form
Is labor Cost ALWAYS Hours*LaborRate? If so, then you should not store it in
the table at all. Just use the expression when you need the labor cost. If you want to fill in labor cost control with a value as a default that you might modify due to circumstances, you would use some VBA to run in the after update event of the Hours and Labor Rate controls If isNull(ME.[LaborCost]) or ME.[LaborCost] = 0 then ME.[LaborCost] = Me.Hours * Me.[LaborRate] End if John Spencer Access MVP 2002-2005, 2007-2009 The Hilltop Institute University of Maryland Baltimore County SteveH wrote: I have a form with two fields. One is called hours and the second is called labor rate. I have a third field called Labor Cost. When a user enters this field, I would like it to default to Hours times Labor Rate. What is the best way to accomplish this? Thanks |
#3
|
|||
|
|||
Calculated Fields on a Form
First, you don't really specify what is in your table, but just
as a point of information this calculated value should *not* be stored in the table. Your table should only have the fields for the Hours and the LaborCost. The calculation should be done on the fly. You could use a calculated field in a query like; Total: [Hours] * [LaborCost] then use that query as the record source of your form. Or, you could use a calculated control (text box) on your form with a Control Source like; =[Hours] * [LaborCost]. -- _________ Sean Bailey "SteveH" wrote: I have a form with two fields. One is called hours and the second is called labor rate. I have a third field called Labor Cost. When a user enters this field, I would like it to default to Hours times Labor Rate. What is the best way to accomplish this? Thanks |
#4
|
|||
|
|||
Calculated Fields on a Form
Steve
To add to what other's have suggested, why bother having the user "enter this field" (I assume you mean tab into it). If the calculation is to be automatic, that control should probably be disabled and not a regular tab stop. After all, you don't want the user to make changes to it, do you? Regards Jeff Boyce Microsoft Office/Access MVP "SteveH" wrote in message ... I have a form with two fields. One is called hours and the second is called labor rate. I have a third field called Labor Cost. When a user enters this field, I would like it to default to Hours times Labor Rate. What is the best way to accomplish this? Thanks |
Thread Tools | |
Display Modes | |
|
|