|
+ |
Dim intClose As Integer '1-( ), 2-( ), 3-( ) Dim intEsc As Integer '1-( ), 2-( ), 3-( ) '------------------------------------------------ Private Sub Form_BeforeUpdate(Cancel As Integer) Dim ctrl As control Set ctrl = Screen.ActiveControl If Me.Dirty = True Then ' Select Case MsgBox(" ?", vbYesNoCancel + vbQuestion, "Info. Form_BeforeUpdate") Case vbYes ' If = True Then ' intClose = 1 Else ' , intClose = 3 End If Case vbNo ' - ??? intEsc = 2 intClose = 2 Me.Undo ' Me.Dirty = False Case vbCancel ' intClose = 3 Cancel = False ctrl.SetFocus Me.Dirty = True ctrl.SetFocus End Select End Sub '------------------------------------------------ Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Dim ctrl As control Set ctrl = Screen.ActiveControl Select Case KeyCode ... Case vbKeyEscape If Me.Dirty = True Then Select Case MsgBox(" ?", vbYesNoCancel + vbQuestion, "Info. Form_KeyDown") Case vbYes ' If = True Then ' intEsc = 1 Else intEsc = 3 End If Case vbNo ' intEsc = 2 Me.Undo ' Me.Dirty = False Case vbCancel ' intEsc = 3 ctrl.SetFocus Me.Dirty = True ctrl.SetFocus End Select Else DoCmd.Close acForm, Me.Name, acSaveNo End If End Select End Sub '------------------------------------------------ Private Sub Form_Undo(Cancel As Integer) Select Case intEsc Case 1 If ( = True) Then ' DoCmd.RunCommand acCmdSaveRecord ... Else ' Cancel = True End If Case 2 ' Cancel = False Case 3 ' Cancel = True End Select End Sub '------------------------------------------------ Private Sub Form_Unload(Cancel As Integer) Dim ctrl As control Set ctrl = Screen.PreviousControl Select Case intClose Case 1 ' Cancel = False Case 2 ' - ??? Cancel = False Case 3 ' Cancel = True ctrl.SetFocus Me.Dirty = True ctrl.SetFocus ' Case Else ' Cancel = False End Select End Sub |
http://www.sql.ru/forum/1267609/otsledit-izmeneniya-na-zakrytie-i-otmenu-formy