RecordSetWrapper is a SQL Recordset automation function in Northwind Database. I understood the issue after .movenext from JamesDeckert.
This worked perfectly.
Dim rsw As New RecordSetWrapper
Code:
If rsw.OpenRecordset("order details", "[Order ID] = " & OrderID) Then
With rsw.Recordset
If Not .EOF Then
Do While Not .EOF
Delete = rsw.Delete
.MoveNext
Loop
End If
End With
End If
If rsw.OpenRecordset("Inventory Transactions", "[Customer Order ID] = " & OrderID) Then
With rsw.Recordset
If Not .EOF Then
Do While Not .EOF
Delete = rsw.Delete
.MoveNext
Loop
End If
End With
End If
Set rsw = Nothing
If rsw.OpenRecordset("Orders", "[Order ID] = " & OrderID) Then
Delete = rsw.Delete
End If
Basically the problem was that the current rsw would delete only one record that matched. We need to to do a loop of all the matching records and delete them.
This site helped in the syntax for recordsetwrapper - https://github.com/jamiewest/VBA-Lib...cordsetWrapper