Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

Calculation in Forms

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AJ - 12 Oct 2005 12:37 GMT
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.
Tom Lake - 12 Oct 2005 13:11 GMT
> Hello
> I have a simple DB file which has Employee details regarding salaries and
[quoted text clipped - 9 lines]
> 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
Klatuu - 12 Oct 2005 13:28 GMT
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.

> Hello
> I have a simple DB file which has Employee details regarding salaries and
[quoted text clipped - 11 lines]
>
> Thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.