Compound Interest



The compound interest is the amount of money earned on a deposit during a period of time. It can be calculated using the following formula:

Compound Interest Formula P = Principal
r = Annual (Interest) Rate
m = Number of Compounding Periods per Year
n = Total Number of Compounding Periods
A = Amount Earned After n periods



Practical Learning: Starting the Exercise

  1. Start Microsoft Access and create a blank database named Compound Interest
  2. On the main menu, click Insert -> Forms
  3. On the New Forms dialog box, make sure Design View is selected and make sure the combo box is empty:
  4. Click OK
  5. Display the Properties window. If you are using MS Access >= 2000, on the Properties window, set the Allow All Design Changes to Design View Only
  6. Save the form as CompInterest
  7. Change its properties as follows:
    Caption:                Compound Interest
    Record Selectors:    No
    Navigation Buttons: No
    Border Style:          Dialog
  8. To add the first control, while the form is selected, on the Toolbox, make sure the Control Wizard button is down . Click the Group Box control and click somewhere in the form
  9. In the first page of the wizard, click under Label Names
  10. Type Monthly and press the down arrow key. Complete the label names with Quarterly, Semiannually, and Annually 
  11. Click Next
  12. Accept to have the default set to Monthly and click Next
  13. Accept the default values and click Next
  14. Accept the Option Buttons and click Next
  15. Set the Caption to Compound Frequency and click Finish
  16. Change the Name of the new group box control to fraFrequency
  17. Design the dialog box and change the properties of the controls as follows:
    GroupBox: Caption: Preparation
    Label Caption TextBox Name Format Decimal Places Default Value
    Principal: txtPrincipal Currency 2 0
    Interest Rate: txtInterestRate Percent   0.0825
    Periods: txtPeriods General Number 0 0
    GroupBox: Caption: Results
    Label Caption TextBox Name Format Decimal Places Default Value
    Interest Earned: txtInterestEarned Currency 2 0
    Amount Earned: txtAmountEarned Currency 2 0
  18. Implement the Click() event of the Calculate button as follows:
    Option Compare Database
    Option Explicit
    Private Sub cmdCalculate_Click()
        Dim Principal As Currency
        Dim InterestRate As Double
        Dim InterestEarned As Currency
        Dim FutureValue As Currency
        Dim RatePerPeriod As Double
        Dim Periods As Integer
        Dim CompoundType As Integer
        Dim i As Double
        Dim n As Integer
        Principal = CCur(txtPrincipal)
        InterestRate = CDbl(txtInterestRate)
        If fraFrequency.Value = 1 Then
            CompoundType = 12
        ElseIf fraFrequency.Value = 2 Then
            CompoundType = 4
        ElseIf fraFrequency.Value = 3 Then
            CompoundType = 2
            CompoundType = 1
        End If
        Periods = CInt(txtPeriods)
        i = InterestRate / CompoundType
        n = CompoundType * Periods
        RatePerPeriod = InterestRate / Periods
        FutureValue = Principal * ((1 + i) ^ n)
        InterestEarned = FutureValue - Principal
        txtInterestEarned = CStr(InterestEarned)
        txtAmountEarned = CStr(FutureValue)
    End Sub
    Private Sub cmdClose_Click()
    On Error GoTo Err_cmdClose_Click
        Exit Sub
        MsgBox Err.Description
        Resume Exit_cmdClose_Click
    End Sub
  19. Test the form



Home Copyright 2003-2012 FunctionX