Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OnDelete Event works in child form, but Stop other Events functioning

Status
Not open for further replies.

noorani

Programmer
Dec 11, 2002
46
FR
I have writen this code for the " child form " in my order main form, for on delete event , this code work fine,

problem is when choosing " No option " at the time of

execution then the delete process stops successfuly. but

other buttons on my main form stop functioning. like delete button for my main form.

may be because i'm using the cancel event at the end of my code for on delete event.

please give me any advise.

here is the code.


Private Sub Form_Delete(Cancel As Integer)
Dim title As String
Dim dbs As Database
Dim wsp As Workspace
Dim D As Recordset
Dim Z As Recordset
title = "BackOffice 1.0.3"

If MsgBox("Record will be deleted. Want to delete (Y/N)?", vbYesNo, title) = vbNo Then GoTo err_prih

Set dbs = CurrentDb
Set wsp = DBEngine.Workspaces(0)
wsp.BeginTrans

'check if this order number of my main form exist in invoice table.

Set D = dbs.OpenRecordset("select * from Invoice_main where Invoice_ref=" & Parent!OrderID, dbOpenDynaset)
If D.RecordCount > 0 Then

MsgBox ("Invoice have been issued on this order, deletion is not possible, please delete the invoice first."), vbCritical, title

wsp.Rollback
dbs.Close
wsp.Close
GoTo err_prih
End If

' here i'm checking products in the reseved table using the Order Number in the main form and Product number in the child form.

Set Z = dbs.OpenRecordset("select * from Reserve where (OrderID=" & Parent!OrderID & ")and(pronumber=" & Me.productid.Column(0) & ")", dbOpenDynaset)
If Z.RecordCount <= 0 Then

MsgBox (&quot;No reserved product found for this order.&quot;), vbCritical, title

Else
Z.delete
wsp.CommitTrans
Z.Close
dbs.Close
wsp.Close
End If

MsgBox (&quot;Record have been deleted&quot;), vbExclamation, title

Exit Sub

err_prih:

Cancel = True
Exit Sub

End Sub


Look forward to any advise.

Thanks in Advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top