Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting default value based on values of two other fields

Status
Not open for further replies.

GinaStar

Technical User
Dec 25, 2002
24
US
I have a labor form that I key driver's labor into daily. I have several fields: dblHours, curRate, curLaborAmt. The default value for curLaborAmt should be curRate*dblHours. (not always though, sometimes labor is paid as straight cash, not paid via an hourly rate so have to be able to override the default value)

What I want to do is set the default value as

=[dblHours]*[dblRate]

Problem is, I can't seem to get the blasted thing to update the curLaborAmt properly after I key in the values in dblHours and curRate. I know that I will need it to recalculate after I key in the dblHours and curRate, but I've tried everything from docmd.recalc to docmd.refresh to docmd.requery. Any suggestions?

Regina Parker
 
Hi Regina,

In the Default Value property of curLaborAmt type in =[curRate] * [dblHours]

In the After UpDate event of both dblHours and dblRate try:

Me!curLaborAmt = Me!dblHours * Me!dblRate

Bill
 
already tried both of those methods and they still wouldn't update. I'm still trying though.

have also tried via vba:

dim lbrAmt as currency

lbrAmt = me!dblHours*Me!dblRate

me.curLaborAmt.value =lbrAmt

(pardon the punctuation on the curLaborAmt.value above, was doing from memory)

that didn't work either
Regina
 
Hi again Regina,

In VBA drop the .value it isn't required and will almost certainly cause problems.

Also when referring to controls in forms or reports it's Me! not Me. (
Send your DB if this doesn't work to billpower@cwcom.net , removing any sensitive records first. Access '97 or 2000 format.

All you're trying to do is update a field, it's got to be something pretty basic, a fresh pair of eyes might help.

All the best

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top