Home

Compound Interest

     

Introduction

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:

   
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 Ribbon, click Create
  3. In the Forms section, click Form Design
  4. Display the Properties window. On the Properties window, set the Allow All Design Changes to Design View Only
  5. Save the form as CompInterest
  6. Change its properties as follows:
    Caption:                Compound Interest
    Record Selectors:    No
    Navigation Buttons: No
    Border Style:          Dialog
  7. To add the first control, while the form is selected, on the Ribbon, make sure the Use Control Wizard button is down. Click the Group Box control and click somewhere in the form
  8. In the first page of the wizard, click under Label Names
  9. Type Monthly and press the down arrow key. Complete the label names with Quarterly, Semiannually, and Annually  
  10. Click Next
  11. Accept to have the default set to Monthly and click Next
  12. Accept the default values and click Next
  13. Accept the Option Buttons and click Next
  14. Set the Caption to Compound Frequency and click Finish
  15. Change the Name of the new group box control to fraFrequency
  16. Design the dialog box and change the properties of the controls as follows:
     
    Compound Interest
    GroupBox: Caption: Preparation
    TextBox
    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
    TextBox
    Label Caption TextBox Name Format Decimal Places Default Value
    Interest Earned: txtInterestEarned Currency 2 0
    Amount Earned: txtAmountEarned Currency 2 0
  17. 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
        Else
            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
    
    
        DoCmd.Close
    
    Exit_cmdClose_Click:
        Exit Sub
    
    Err_cmdClose_Click:
        MsgBox Err.Description
        Resume Exit_cmdClose_Click
        
    End Sub
  18. Test the form
 
 
     
 

Home Copyright © 2010-2013 FunctionX