You are on page 1of 3

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:

GroupBox: Caption: Preparation

TextBox Label Caption Principal: Interest Rate: Periods: TextBox Label Caption Interest Earned: Amount Earned: TextBox Name txtInterestEarned txtAmountEarned Format Currency Currency Decimal Places 2 2 Default Value 0 0 TextBox Name txtPrincipal txtInterestRate txtPeriods Format Currency Percent General Number 0 Decimal Places 2 Default Value 0 0.0825 0

GroupBox: Caption: Results

17. Implement the Click() event of the Calculate button as follows: Option Compare Database Option Explicit Private Dim Dim Dim Dim Dim Dim Dim Dim Dim Sub cmdCalculate_Click() Principal As Currency InterestRate As Double InterestEarned As Currency FutureValue As Currency RatePerPeriod As Double Periods As Integer CompoundType As Integer i As Double 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-2012 FunctionX

You might also like