Oncancel for form vs Onquerycancel for pages

2927
0
11-07-2012 08:44 AM
DanKlenjoski
New Contributor II
I have an axf with a custom form that collects street signs. It links to a related table. The field crews mistakenly hit the red X sometimes after collecting signs instead of the OK. I searched the forums for code that will ask them if they intended to cancel.
Here is the code.

Sub OnFormCancel
Dim bResult
bResult = Application.MessageBox ("Are you sure you want to cancel?", apYesNo, "Cancel?")
If bResult = apNo Then
  ThisEvent.Result = False
End If
If bResult = apYes Then
  ThisEvent.Result = True
End If
End Sub

When I place the call event in the page property events under onquerycancel, it works when they hit the cancel button, yes or no. The code doesn't work on the form properties event under oncancel. It will ask them if they want to cancel but if they click No, the form closes anyway and deletes the point.

Am I missing something?
Tags (3)
0 Kudos
0 Replies