A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Calculated Fields on a Form



 
 
Thread Tools Display Modes
  #1  
Old July 17th, 2009, 04:01 PM posted to microsoft.public.access.gettingstarted
SteveH
external usenet poster
 
Posts: 69
Default 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  
Old July 17th, 2009, 05:10 PM posted to microsoft.public.access.gettingstarted
John Spencer
external usenet poster
 
Posts: 7,815
Default 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  
Old July 17th, 2009, 05:20 PM posted to microsoft.public.access.gettingstarted
Beetle
external usenet poster
 
Posts: 1,254
Default 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  
Old July 17th, 2009, 09:26 PM posted to microsoft.public.access.gettingstarted
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.