form field calculation

piet123

piet
Local time
Today, 18:59
Joined
May 24, 2004
Messages
66
new to access, please help. I have a main form "member detail" (based on a table) and a field named "salary". When the user types a value into the salary field, the field must perform a calculation of [salary]/12 and then display the result in that same field: for example, the user types 80,500 in the salary field and when he leaves the field it displays 6708.33 and the 6708.33 is then the value in the underlying table's field. How do I do this ?

Thank you in advance.
Piet.
 
I would have a hidden field that receives the yearly salary (via code) from the first field when the user types in the amount, then refer to that hidden field on exit of the first field to do the calculation then repopulate the first field with the monthly figure.

So on exit of the first field you'd need

Me.HiddenField = Me.YearFigureField

Me.YearFigureField = Me.HiddenField / 12

There's probably a better way though

Col
 
Could try after update event

Private Sub Salary_AfterUpdate()
Me!Salary = Me!Salary/ 12
End Sub
 
thanks colin

thank you for the reply, will try that.

ColinEssex said:
I would have a hidden field that receives the yearly salary (via code) from the first field when the user types in the amount, then refer to that hidden field on exit of the first field to do the calculation then repopulate the first field with the monthly figure.

So on exit of the first field you'd need

Me.HiddenField = Me.YearFigureField

Me.YearFigureField = Me.HiddenField / 12

There's probably a better way though

Col
 
Last edited:

Users who are viewing this thread

Back
Top Bottom