Calculation in Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
I have a simple DB file which has Employee details regarding salaries and
allwoances and deductions.
I created a form to suit my needs but when it comes to the calculation part
of it, I always fail even though I tried looking up in the Help menu.
For example, there are a fields for basic, OT1,OT2, allowances, claim1,
claim2, deduct1, deduct2, deduct3. I would like to do the following
calculation on the form:
sub total A = basic+OT1+OT2
sub total B= allowances+claim1+claim2
sub total C= deduct1+deduct2+deduct3
grand total D=A+B-C
A seperate box to show a mix of text + grand total D & date

Thanks in advance.
 
AJ said:
Hello
I have a simple DB file which has Employee details regarding salaries and
allwoances and deductions.
I created a form to suit my needs but when it comes to the calculation
part
of it, I always fail even though I tried looking up in the Help menu.
For example, there are a fields for basic, OT1,OT2, allowances, claim1,
claim2, deduct1, deduct2, deduct3. I would like to do the following
calculation on the form:
sub total A = basic+OT1+OT2
sub total B= allowances+claim1+claim2
sub total C= deduct1+deduct2+deduct3
grand total D=A+B-C

Try this:

grand total D = basic+OT1+OT2 + allowances+claim1+claim2 -
(deduct1+deduct2+deduct3)

Tom Lake
 
This will take a little coding for the calculations, bue it isn't that
difficult. I will use SubTotalA as an example. The others will be the same
with different names.
First, create a Sub in your form module to do the calculation. Use a Sub
because the calculation will have to be done in several places.

Sub CalcSubTotalA
Me.SubTotalA = Me.Basic + Me.OT1 + Me.OT2
Me.GrandTotal = Me.Basic + Me.OT1 + Me.OT2 + Me.Allowances _
+ Me.Claim1 + Me.Claim2 - Me.Deduct1 - Me.Deduct2 - Me.Deduct3
End Sub

In the After Update event of Basic, OT1, and OT2, call the sub:
Call CalcSubTotalA

Create two more Subs like the CalcSubTotalA for CalcSubTotalB and
CalcSubTotalC
Then in the Current event of the form you will need to call all three Subs
to display the information for existing records. Do NOT carry the sub totals
or grand total in your records. So, in the Current event of the form:
Call CalcSubTotalA
Call CalcSubTotalB
Call CalcSubTotalC

I don't recommend you mix text, the grand total, and date into one text box.
That would be messy. Instead, create a separate text box for each of the
three.
 
Back
Top