Question Loan Amortization Schedule

anski

Registered User.
Local time
Today, 13:37
Joined
Sep 5, 2009
Messages
93
I need to create a Loan Database Management Program. What's critical is the creation of the amortization schedule. I know that this is easier done in Excel. But I need to do this in Access.

After the user enters the loan amount, interest, terms, etc., I want the program to be able to create an editable form showing the amortization schedule. The user can then edit (if needed) either the principal amount or the interest amount. I have attached an Excel file that does what I need. How can I do this in Access?

Thanks. :)
 

Attachments

Presumably you are familiar with the calculation that is performed in your Excel version, in which case I don't see why you can't apply that to Access. Just need to create a table which will in effect be your repayment schedule which will hold the column values as in your Excel. That table will need a foreign key that will link to a LoanID. You could create a form which run off a Loan table (or with unbound text boxes) that the user will enter the same values as in your Excel ver, ie Loan amount, interest rate, number of payments etc. This could autogenerate a LoanID which can be used in the schedule creation. Once all the required Loan details have been entered you could use a button 'Create Schedule' to fire a function you'd need to write in vba that would create records in the repayment schedule table where each value is calculated in the same way your Excel works. Once all records have been created, this can then be displayed in a sub form under where user entered the loan details. I'm not familiar with how the interest is calculated as the loan is paid off, so couldn't say what the calculation would look like
David
 
Thanks for replying. My main problem was how to create the schedule (like create rows equal to the payment tenor). If the loan is payable in 10 months, Access should be able to create 10 rows for each of the month.

I've figured out a way to do this by using a macro. Since I'm not a programmer (I'm more of a finance person), I had to find a way to do this without using VBA. I am more comfortable with macros.

I used setvalue and gotorecord (next). The macro continues until the total rows (dcount) is already equal to the payment tenor :rolleyes:
 
Hi Anski, please can you assist as I'm faced with a similar situation: I have already created a loan form with a repayment schedule subform created from a schedule table! I'm a newbie to access and vba programming! Thanks
 
It's not that hard in Access but the logic of macros is so bizarre I wouldn't even consider doing it that way. Hopefully, I haven't left out any important pieces. The PropertyID and StartDate are passed in to the CreateAmortization Procedure. You will probably have to modify the code because you never said how you actually wanted to use it.

The procedure deletes existing records for this property and then recreates them. Some information used in the calculation is obtained from a recordset that was opened in a prior procedure.

Code:
Option Compare Database
Option Explicit

Private db As DAO.Database
Private rs As DAO.Recordset
Private qd As DAO.QueryDef
Private td As DAO.TableDef
Private rsMtg As DAO.Recordset
Private qdMtg As DAO.QueryDef

Public Sub CreateAmortization(PropertyId As Variant, StartDate As Variant)
    
On Error GoTo Err_Proc
    If IsNull(PropertyId) Then
        MsgBox "Plese select a propertyID", vbOKOnly
        Exit Sub
    End If
    If Not IsDate(StartDate) Then
        MsgBox "Please select a start date.", vbOKOnly
        Exit Sub
    End If
     DoCmd.RunCommand acCmdSaveRecord
    DoCmd.RunMacro "mWarningsOff"
    DoCmd.OpenQuery "qDelAmortization"
    DoCmd.RunMacro "mWarningsOn"   
    Set db = CurrentDb()
    Set qdMtg = db.QueryDefs!qMtgForProperty
        qdMtg.Parameters![EnterPropertyID] = PropertyId
    Set rsMtg = qdMtg.OpenRecordset
    Do Until rsMtg.EOF = True
        Call WriteRecs(CDate(StartDate))
        rsMtg.MoveNext
    Loop
    
Exit_Proc:
    Exit Sub
Err_Proc:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume Exit_Proc
    End Select
End Sub
Public Sub WriteRecs(StartDate As Date)

    Dim Mths As Integer
    Dim PmtNum As Integer
    Dim BeginningBal As Currency
    Dim EndingBal As Currency
    Dim PmtDate As Date
    Dim CumInt As Currency
    Dim SchedPmt As Currency
    Dim IntRate As Double
    Dim PmtsPerYear As Integer
    Dim MtgAmt As Currency
    Dim MtgTerm As Integer
    Dim PmtYear As Integer
    Dim PmtMonth As Integer

On Error GoTo Exit_Proc

    Set td = db.TableDefs!tblAmortization
    Set rs = td.OpenRecordset
    
    Mths = rsMtg!MortgageTermYears * 12
    BeginningBal = rsMtg!MortgageAmt
    PmtDate = StartDate
    CumInt = 0
    IntRate = rsMtg!InterestRate
    PmtsPerYear = Nz(rsMtg!PmtsPerYear, 12)
    MtgAmt = rsMtg!MortgageAmt
    MtgTerm = rsMtg!MortgageTermYears
    SchedPmt = -Pmt(IntRate / PmtsPerYear, MtgTerm * PmtsPerYear, MtgAmt, 0, 0)
    PmtYear = 1
    PmtMonth = 1
    
    PmtNum = 1
    Do Until PmtNum > Mths
        rs.AddNew
        rs!MortgageID = rsMtg!MortgageID
        rs!PmtNum = PmtNum
        rs!PmtYear = PmtYear
        rs!PmtMonth = PmtMonth
        rs!PmtDate = PmtDate
        rs!BeginningBal = BeginningBal
        rs!SchedPmt = SchedPmt
        rs!ExtraPmt = Nz(rsMtg!ExtraPmt, 0)
        rs!TotPmt = SchedPmt + rs!ExtraPmt
        rs!Interest = BeginningBal * (IntRate / PmtsPerYear)
        rs!Principal = rs!TotPmt - rs!Interest
        rs!EndingBal = BeginningBal - rs!Principal
        CumInt = CumInt + rs!Interest
        rs!CumInterest = CumInt
        BeginningBal = rs!EndingBal
        PmtNum = PmtNum + 1
        PmtDate = DateAdd("m", 1, PmtDate)
        rs.Update
        PmtMonth = PmtMonth + 1
        If PmtMonth > 12 Then
            PmtYear = PmtYear + 1
            PmtMonth = 1
        End If
    Loop
    
    
Exit_Proc:
    Exit Sub
Err_Proc:
    Select Case Err.Number
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume Exit_Proc
    End Select
End Sub
 

Attachments

  • AmortTable.JPG
    AmortTable.JPG
    39.7 KB · Views: 1,461
Waoh! Pat Hartman, U've made my day! I'm so grateful. Thanks & Again Thanks! This is as explicit as it can ever be! Based on what I have created (tables and forms etc) I will modify as required but I'll still need to SEROIUSLY study, analyze your solution so as to get a better understanding (understand the why behind the solution) and so improve on my journey to an Access expert level. As I said I'm a newbie to Access and PROMISE to study to show myself worthy of your feedback, so I can also contribute similarly to others lost in the Access maze!!

2ndly: Regards the lack of details, I didn't want to fall foul to forum's rules because I have earlier made a post in another forum(forum rules also barring me from posting links, but I was explicit on the details in the Modules and VBA forum: my query was Recordsets and VBA!)

Thanks once more!

Though I did not attach an upload of d database file, which I will do later on.
 
Last edited:
Hi Richar3dner & all, Thanks for your offer! Please can you check the Modules & VBA forum because I have posted an explicit description of my problem: I don't know if it's okay to restate the issue here or elaborate in the former post. Waiting for a response so I can know how to proceed.
Also, regards the solution by Pat Hartman: I'm not quite clear on the use of querydef and tabledef, rsMtg & qdMtg(what's their use) and regards the AmortTable.jpg file, my schedule table is almost exactly alike except for the RecID(mine is ScheduleID) and UpdateDate??? (which I don't have on mine).
Thanks
 
@jmeni, please post a link in the other thread to this one and vice versa. And in the future, please don't start multiple threads on the same topic.

I didn't write this code specifically for you. It was something I had written for a product I am selling so it only took me about 15 minutes to find it and cut and paste the relevant pieces, but some people will actually write and test code before posting it for you. It is never good to have folks working at cross-purposes or wasting their time if you already have a solution. Since I am a moderator, I can merge the threads if you want me to. This is a very friendly place but people will become unfriendly if you are a constant double poster. Consider this advice even when posting to other forums.

Always tell people you have open posts on the same topic elsewhere and provide a link if allowed.
 
Dear Pat Hartman,
So sorry for not mentioning that I have an open post! Also I can't post the link to my earlier post as I'm yet to hit the minimum number(10 post) before I can post links to post. But you can merge the post as you have suggested and also my earlier post is in the Modules & VBA forum, the title is Recordsets and VBA by Jmeni.

I'm yet to have a full solution to my post, but I'll keep my subsequent post to the other post in the Modules & VBA post.
Thanks.
 
hi guys...need some help here...
i need to create a sample access dabase with code vba like loan amortization dbs .but step by step from A to Z
 

Users who are viewing this thread

Back
Top Bottom