GulfImages
Technical User
Hello,
I have some code that runs on a payment form that goes into my Order Table and marks paid to true or false based on the payment amount subtracted from the order amount, here is the code:
--------
Dim PdI As Database, PdOrd As Recordset
Set PdI = DBEngine.Workspaces(0).Databases(0)
Set PdOrd = PdI.OpenRecordset("tblInvoices", DB_OPEN_TABLE)
PdOrd.Index = "OrderID"
PdOrd.Seek "=", OrdID
PdOrd.Edit
If IsPaid(OrdID) Then PdOrd!InvPaid = -1
If IsPaid(OrdID) = 0 Then PdOrd!InvPaid = 0
PdOrd.Update
PdOrd.Close
Set PdI = Nothing
Set PdOrd = Nothing
------------
This works perfectly on the afterinsert and afterupdate events of the payments form but when I delete a record it will give me the following error:
Run Time Error '3021'
No Current Record
It's happening on the PdOrd.Update portion of the code.
I've tried it on the OnDelete and AfterDelConfirm events of my payment form, but it is obviously happening because the record is already deleted and OrderID is no longer a valid variable. The payment is deleted but the Invoice is still marked as paid.
Any Ideas?
Thanks,
Bobby Cunningham
I have some code that runs on a payment form that goes into my Order Table and marks paid to true or false based on the payment amount subtracted from the order amount, here is the code:
--------
Dim PdI As Database, PdOrd As Recordset
Set PdI = DBEngine.Workspaces(0).Databases(0)
Set PdOrd = PdI.OpenRecordset("tblInvoices", DB_OPEN_TABLE)
PdOrd.Index = "OrderID"
PdOrd.Seek "=", OrdID
PdOrd.Edit
If IsPaid(OrdID) Then PdOrd!InvPaid = -1
If IsPaid(OrdID) = 0 Then PdOrd!InvPaid = 0
PdOrd.Update
PdOrd.Close
Set PdI = Nothing
Set PdOrd = Nothing
------------
This works perfectly on the afterinsert and afterupdate events of the payments form but when I delete a record it will give me the following error:
Run Time Error '3021'
No Current Record
It's happening on the PdOrd.Update portion of the code.
I've tried it on the OnDelete and AfterDelConfirm events of my payment form, but it is obviously happening because the record is already deleted and OrderID is no longer a valid variable. The payment is deleted but the Invoice is still marked as paid.
Any Ideas?
Thanks,
Bobby Cunningham