S
Stephen Lynch
When I try and run my code, the append to table for the date field shows the
time only and a date of 12/31/1899.
I have tried everything, Format(), using a hard date in the code, etc.
The table field 6 is set to ShortDate for the import.
This is my line for the append in the loop: PD = Format(StartDate,
"mm/dd/yyyy")
Do I have my variable types wrong? URGGG!
Any help is appreciated.
STEVE
Function LoanAmort2(BeginPrincipal As Currency, InterestRate As Double,
Frequency As Double, TotPmts As Double, StartDate As Date)
Dim FVal As Double
Dim PayType As Double
Dim Payment As Currency
Dim Period As Integer
Dim P As Currency 'Principal Payment
Dim I As Currency 'Interest Payment
Dim EB As Currency 'Ending Balance
Dim RemainBalance As Currency
Dim PD As Date 'Payment Date
FVal = 0 ' Usually 0 for a loan.
If InterestRate > 1 Then InterestRate = InterestRate / 100 ' Ensure
proper form.
PayType = 0 'Payments made at the beginning of the month
Payment = Abs(-Pmt(InterestRate / Frequency, TotPmts, BeginPrincipal, FVal,
PayType))
RemainBalance = BeginPrincipal
'loop through each payment
For Period = 1 To TotPmts
EB = RemainBalance
P = PPmt(InterestRate / Frequency, Period, TotPmts, -BeginPrincipal,
FVal, PayType)
P = (Int((P + 0.005) * 100) / 100) ' Round principal.
I = Payment - P
I = (Int((I + 0.005) * 100) / 100) ' Round interest.
PD = Format(StartDate, "mm/dd/yyyy")
EB = RemainBalance - P
RemainBalance = EB
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Table1 (1,2,3,4,5,6) SELECT (" & Period & ")AS
1,(" & P & ")AS 2,(" & I & ")AS 3 ,(" & Payment & ")AS 4,(" & EB & ")AS 5,("
& PD & ")AS 6;"
Next
End Function
time only and a date of 12/31/1899.
I have tried everything, Format(), using a hard date in the code, etc.
The table field 6 is set to ShortDate for the import.
This is my line for the append in the loop: PD = Format(StartDate,
"mm/dd/yyyy")
Do I have my variable types wrong? URGGG!
Any help is appreciated.
STEVE
Function LoanAmort2(BeginPrincipal As Currency, InterestRate As Double,
Frequency As Double, TotPmts As Double, StartDate As Date)
Dim FVal As Double
Dim PayType As Double
Dim Payment As Currency
Dim Period As Integer
Dim P As Currency 'Principal Payment
Dim I As Currency 'Interest Payment
Dim EB As Currency 'Ending Balance
Dim RemainBalance As Currency
Dim PD As Date 'Payment Date
FVal = 0 ' Usually 0 for a loan.
If InterestRate > 1 Then InterestRate = InterestRate / 100 ' Ensure
proper form.
PayType = 0 'Payments made at the beginning of the month
Payment = Abs(-Pmt(InterestRate / Frequency, TotPmts, BeginPrincipal, FVal,
PayType))
RemainBalance = BeginPrincipal
'loop through each payment
For Period = 1 To TotPmts
EB = RemainBalance
P = PPmt(InterestRate / Frequency, Period, TotPmts, -BeginPrincipal,
FVal, PayType)
P = (Int((P + 0.005) * 100) / 100) ' Round principal.
I = Payment - P
I = (Int((I + 0.005) * 100) / 100) ' Round interest.
PD = Format(StartDate, "mm/dd/yyyy")
EB = RemainBalance - P
RemainBalance = EB
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO Table1 (1,2,3,4,5,6) SELECT (" & Period & ")AS
1,(" & P & ")AS 2,(" & I & ")AS 3 ,(" & Payment & ")AS 4,(" & EB & ")AS 5,("
& PD & ")AS 6;"
Next
End Function