I'm trying to set up certain fields in a form to have autocalculated values based on values in preceding fields.
For example this is what I tried for a field whose value should be 20% of a preceding field:
Code:
Private Sub Tax_BeforeUpdate(Cancel As Integer)
If IsNull(Me!Labour) Then Exit Sub
Me!Tax = (Me!Labour * 0.2)
End Sub
But this doesn't autofill for some reason, it just ignores any value entered (it doesn't give a syntax error in the code editor so I assume that that's ok at least).
Basically I need this field to automatically fill in with a value of 20% of the other field. I also have another calculation which is basically:
NetValue = 0 - (Labour + Materials)
And a third which is:
GrossValue = NetValue + Tax (Tax being the field in the code above)
They should also round to 2 decimal places if possible.
Can't see how this can be done though?
(I did try using a Query Design as suggested elsewhere on the net- it seems such a messy convoluted way for a simple calculation, and although I could make thre query work in table view, I couldn't see how it could be inserted into the form so the calculated result is visible. Also I have another problem with it because we already have some values in the Transactions table for Tax, which were entered manually by the users- so if this field suddenly becomes autocalculated it could cause issues with the data that's already there...)