I keep on getting the above error. The rs.MoveNext is highlighted when the error occurs. I'm extracting a selection of related records from a much larger file onto DdTransTemp and then going through that DdTransTemp file and processing certain transactions that full into a From and To date range.
All of the Dims are OK
Using Access 2016
I hope someone can help
All of the Dims are OK
Using Access 2016
I hope someone can help
Code:
Dim IntDaysCount As Integer
Dim lUserID As Long
Dim db As DAO.Database
Dim rs As DAO.Recordset
DBEngine.SetOption dbMaxLocksPerFile, 1000000
On Error GoTo ErrTrap1
TaskCompletedFld = 0
IntDaysCount = 0
Me.QryFile = strQryFile
lUserID = Me.UserIdFld.Value
Me.DaysOfIntFld = 0
PeriodInterestFld = 0
RecCounter = 1
PayPeriodDateFld = Me.FirstDateFld
Set db = CurrentDb
Set rs = db.OpenRecordset("DdTransTemp", dbOpenTable)
If Not (rs.EOF And rs.BOF) Then '----- Is there any transactions in this period
rs.MoveFirst ' Unnecessary in this case, but still a good habit
Do While Not rs.EOF
Me.DdSchedTransIdFld = rs![DdSchedTransId]
Me.TransCodeFld = rs![TransCode]
Me.DdSchedIdFld = rs![DdSchedId]
Me.MatterIdFld = rs![MatterId]
Me.MatterTitleFld = rs![MatterTitle]
Me.MatterNoFld = rs![MatterNo]
Me.DueDateFld = rs![DueDate]
Me.DueAmountFld = rs![DueAmount]
Me.DDAmountFld = rs![DDAmount]
Me.DaysOfIntFld = rs![DaysOfInt]
Me.TransStatusFld = rs![Status]
Me.ABADateFld = rs![ABADate]
Me.TransDateFld = rs![TransDate]
Me.RefNoFld = rs![RefNo]
'MsgBox "Current Record number = " & DdSchedTransIdFld & " TransCode = " & TransCodeFld & " DDSchedIdFld = " & DdSchedIdFld & " Amount = " & Me.DueAmountFld
' ----- Process this transaction ------------------------
' ----------------------------------I need to apply the Interest for each day of the period
If Me.DueDateFld >= Me.PayPeriodDateFld And Me.DueDateFld <= Me.LastDateFld Then
Select Case Me.TransCodeFld
Case 13, 50, 20 ' ----- 13 = Direct debit, 50 = Direct Credit, 20 = Manual Payment
RunningDebtTotal = Round((RunningDebtTotal - Me.DueAmountFld), 2) ' Update the total debt at that time
'----DueDateFld updated here
'If Me.TransCodeFld = 13 Then
' Me.IntDueDateFld = Me.DueDateFld ' Me.DueDateFld
' End If
Case 30, 35, 40, 60 '------ 30 = Dis Hon, 35 = Penalty Fee, 40 = Interest, 60 = Transaction Fee
RunningDebtTotal = RunningDebtTotal + Me.DueAmountFld ' Update the total debt at that time
End Select
End If
' ------- Calculate the Interest daily and accumulate it for the Pay Period, then write the Int transaction
Me.PayPeriodDateFld = Me.PayPeriodDateFld + 1
Me.PeriodInterestFld = Round(Me.PeriodInterestFld + (RunningDebtTotal * (((Me.InterestRateFld / 100)) / 365) * 1), 2)
RunningDebtTotal = Round(RunningDebtTotal + (RunningDebtTotal * (((Me.InterestRateFld / 100)) / 365) * 1), 2)
IntDaysCount = IntDaysCount + 1
JumpToHere1:
RecCounter = RecCounter + 1
rs.MoveNext
Loop