I have a dataset retrieved from a database and need to add a row to it under certain conditions. I have the code:-
Try
With Me.DStrn.Tables("Transacti
ons")
For Each DR In .Rows
If DR.Item("XactType") = 3 And DR.Item("VatDiscAmt") <> 0 Then
HoldDisc = DR.Item("VatDiscAmt")
DR = DStrn.Tables("Transactions
").NewRow
DR("AlphType") = "Disc."
DR("TotalPosting") = HoldDisc
DR("TrnId") = 0
DR("InvSource") = ""
DR("XactDate") = Today
DR("XactType") = 0
DR("XactStatus") = 0
DR("OurRef") = ""
DR("YourRef") = ""
DR("LoadCard") = ""
DR("PaymtDueDate") = Today
DR("AlphType") = ""
DR("NonDiscTotal") = HoldDisc
DR("RunningBal") = -99999999.99
DR("AmountAllocated") = 0
DR("VatDiscAmt") = 0
DStrn.Tables("Transactions
").Rows.In
sertAt(DR,
0)
End If
Next
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
his comes up with an exception message "Collection was Modified; enumeration operation might not execute and bombs me out,
Any ideas anyone?
Start Free Trial