[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.3

adding a date to a vba code to increase the date each month by 1 month

Asked by andybrooke in Microsoft Access Database, Access Forms, VB Database Programming

Tags: access vba code

I have downloaded a sample database which I have adapted to function to suit its purpose (already with loads of help on this forum)
My last problem is:
on the main form it asks you to input "Date Of 1st Payment"
Then when you press calculate it gives an amorization of payments, HOWEVER I want each row under the column "PaymentDate" to increase each row by one calander month.
I have atached a copy of the database to give an example

if you open the atached database and input the following:

Total Available each Month: £250

Clients total creditors: 10
total Debt: £10000

How Many Qualify For The Plan: £6
Total debt: £6000

Date Of 1st Payment: 01/11/2009

as you will see when you press calculate it inputs the same date "01/11/2009" on each row. I want each row to add 1 month
starting on the 1st row with the date on the main form.
For example.
row 1  01/11/2009
row 2  01/12/2009
row 3  01/01/2010
Etc.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
Private Sub btnCalculate_Click()
Dim rs As Recordset
Dim response
Dim strSQL As String
Dim dblMthRate, dblCapital As Double
Dim x As Long
 
Me.duration = Int(Me.amount / (Me.payment2 - (Me.payment2 / 100 * 16 + Text0)) + 1)
Me.Months = Me.duration
        Me.Requery
 
 
If IsNull(Me.Capital_Amount.Value) Or Me.Capital_Amount.Value = 0 Then
   response = MsgBox("Capital Value not Set", vbOKOnly)
Else
    If IsNull(Me.Months.Value) Or Me.Months.Value = 0 Then
        response = MsgBox("Loan Period not Set", vbOKOnly)
    Else
        dblMthRate = ((1 + Me.Apr) ^ (1 / 12)) - 1
        Me.Pament.Value = Me.payment2
        strSQL = "DELETE [tbl Loan schedule].*, [tbl Loan schedule].[Loan Id] " & _
                 "FROM [tbl Loan schedule] " & _
                 "WHERE ((([tbl Loan schedule].[Loan Id])=" & Str(Me.Loan_Id.Value) & "));"
        DoCmd.SetWarnings False
        DoCmd.RunSQL (strSQL)
        Set rs = CurrentDb.OpenRecordset("tbl Loan schedule")
        dblCapital = Me.Capital_Amount.Value
 
        For x = 1 To Me.Months.Value
            rs.AddNew
            rs![Loan Id] = Me.Loan_Id.Value
            rs!PaymentDate = Me.Text21
            rs!Month = x
            rs!capital = dblCapital
            rs!interest = Round(dblCapital * dblMthRate, 2)
            rs!Payment = Me.Pament.Value
            rs!CredsPaymentDMP = Me.Text4
            rs!CredsPaymentDR = Me.Text2
            rs!AdminFee = Me.payment2 * 0.16
            rs!PlanPayment = rs!Payment - rs!CredsPaymentDMP - rs!CredsPaymentDR - rs!AdminFee
            rs!balance = rs!capital + rs!interest - rs!PlanPayment
 
            If rs!balance > 0 Then
 
rs!balance = rs!balance
 
Else
 
rs!balance = 0
 
rs!Payment = rs!capital + rs!CredsPaymentDMP + rs!CredsPaymentDR + rs!AdminFee
 
rs!PlanPayment = rs!capital
End If
 
            dblCapital = rs!balance
 
 
            rs.Update
        
        
        Next
        rs.Close
        Set rs = Nothing
        Me.Refresh
        Me.Repaint
        Me.Requery
    End If
End If
End Sub
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click
 
Dim stDocName As String
 
 
    DoCmd.Close
 
Exit_Command27_Click:
    Exit Sub
 
Err_Command27_Click:
    MsgBox Err.Description
    Resume Exit_Command27_Click
    
End Sub
Attachments:
 
sample database with my alterations
 
[+][-]10/28/09 07:09 AM, ID: 25683369Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Microsoft Access Database, Access Forms, VB Database Programming
Tags: access vba code
Sign Up Now!
Solution Provided By: Dhaest
Participating Experts: 2
Solution Grade: A
 
[+][-]10/28/09 07:13 AM, ID: 25683408Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625