Stuck on an expression (1 Viewer)

sirron

New member
Local time
Yesterday, 16:49
Joined
Nov 23, 2011
Messages
3
Currently self learning access 2010 and i am stuck on an expression

i have a a field called "repairitem" that can be one of 3 items
bike-mechanical-electrical

i have another field called "labourrateperhour"
i want an expesssion that will say

if "repairitem" = bike then "labourrateperhour" is $15
if "repairitem" = mechanical then "labourrateperhour" is $20
if "repairitem" = electrical then "labourrateperhour" is $25

thaks in advance for the help
 

AlexN

Registered User.
Local time
Today, 02:49
Joined
Nov 10, 2014
Messages
302

smig

Registered User.
Local time
Today, 02:49
Joined
Nov 25, 2009
Messages
2,209
A calculated value should not be saved into a field. They should be calculated when required
 

sirron

New member
Local time
Yesterday, 16:49
Joined
Nov 23, 2011
Messages
3
Code:
If "repairitem" ="bike" then
[labourrateperhour].Value = $15
else 
If "repairitem" ="mechanical" then
[labourrateperhour].Value = $20
else 
[labourrateperhour].Value =$25
end if
end if
something like that. Not tested.



sorry for being stupid but how do i enter code like this into access 2010. The code looks exactly what i want
 

AlexN

Registered User.
Local time
Today, 02:49
Joined
Nov 10, 2014
Messages
302
Assuming that you have a data entry form which gives values to your table, you can put this code in the AfterUpdate event of the "repairitem" field. Everytime this field changes value, the "labourateperhour" field's value will change accordingly.
Keep under consideration though, what smig stated beneath.
 

Users who are viewing this thread

Top Bottom