I want to step through a Query file. I keep getting an error "Item not found in collection"
The Query file DdFixPaymentFeeQry has 752 records on it. I had it going on a different version of the project and i wanted to make a few tweaks, now I don't know what I have changed
-------------------------------------------------------------------------------------------------------------------------------------------------------------
I Would really appreciate some help on this if anyone is available.
The Query file DdFixPaymentFeeQry has 752 records on it. I had it going on a different version of the project and i wanted to make a few tweaks, now I don't know what I have changed
Code:
Private Sub Form_Load()
'--------------------------------- the loop Setup Starts here - -------------------------------
Dim strQryFileSql, strQryFile As String
Dim strWhereStmnt As String
Dim dbs As Database
Dim RecCounter, PreviousRec, FirstRec As Integer
Dim TaskCompleted As Integer
Dim rsQuery As DAO.Recordset
Dim lUserID As Long
DBEngine.SetOption dbMaxLocksPerFile, 1000000
On Error GoTo ErrTrap
TaskCompleted = 0
strQryFile = "DdFixPaymentFeeQry"
Me.QryFileFld = strQryFile
Set dbs = CurrentDb()
strQryFileSql = "SELECT * FROM " & strQryFile '
Set rsQuery = dbs.OpenRecordset(strQryFileSql, dbOpenDynaset)
Me.CurrentSchedId = 0
PreviousRec = 0
FirstRec = 0
'----------------------------------------------------------------------------------------------
'----------------- The LOOP starts Here -------------------------------------------------------
RecCounter = 1
If (rsQuery.BOF And rsQuery.EOF) Then
MsgBox "There's no records on the incoming file - DdFixPaymentFeeQry"
Exit Sub
End If
Do While Not rsQuery.EOF
Me.DdSchedIdFld = rsQuery![DdSchedId] '--- has the Schedule Id changed ? -----------------
If Me.DdSchedIdFld <> Me.CurrentSchedId Then
Me.CurrentSchedId = Me.DdSchedIdFld '----save the DdSchedId
Me.PaymentFeeFld = DLookup("PaymentFee", "DdSchedules", "DdSchedId = " & Me.CurrentSchedId)
End If
If PreviousRec = 13 And rsQuery![TransCode] = 13 Then
'---- then create Transaction fee transaction ---------------
DoCmd.SetWarnings False
DoCmd.OpenQuery "AddTransPaymentFeeFixQry" ' create the Transaction fee record for this payment transaction
DoCmd.SetWarnings True
End If
Me.TransCodeFld = rsQuery![TransCode]
Me.DdSchedIdFld = rsQuery![DdSchedId]
Me.MatterIdFld = rsQuery![MatterId]
Me.MatterNoFld = rsQuery![DdSchedules.MatterNo]
Me.MatterTitleFld = rsQuery![MatterTitle]
Me.DueDateFld = rsQuery![DueDate]
Me.DueAmountFld = rsQuery![DueAmount]
Me.DDAmountFld = rsQuery![DDAmount]
Me.DaysOfIntFld = rsQuery![DaysOfInt]
Me.TransStatusFld = rsQuery![TransStatus]
Me.DdSchedTransIdFld = rsQuery![DdSchedTransId]
Me.ABADateFld = rsQuery![ABADate]
Me.TransDateFld = rsQuery![TransDate]
Me.RefNoFld = rsQuery![RefNo]
PreviousRec = Me.TransCodeFld
rsQuery.MoveNext
Me.DaysOfIntFld = 0
' ----- Process this transaction ------------------------
JumpToHere:
Loop
' -----------------------------------------------------------------------------------------------------------------------------------
ErrTrap:
Select Case err.Number
Case 94, 5941
'Loop to the next one
GoTo JumpToHere
Case Else
MsgBox err.Number & " - " & err.Description, vbCritical
Resume
End Select
'------------------------------------------------------------------------------------
rsQuery.Close
Set rsQuery = Nothing
End Sub
-------------------------------------------------------------------------------------------------------------------------------------------------------------
I Would really appreciate some help on this if anyone is available.