Private Sub Form_BeforeUpdate(Cancel As Integer)
If Checkme <> True Then
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & "Do you wish to save the changes?" & Chr(13)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
Select Case MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?")
Case Is = vbYes
'MsgBox "Yes"
'do nothing
Case Is = vbNo
'MsgBox "No"
DoCmd.RunCommand acCmdUndo
CancelYes = False
Case Is = vbCancel
'MsgBox "Cancel"
CancelYes = True
DoCmd.RunCommand acCmdUndo
DoCmd.RunCommand acCmdRedo
End Select
End If
End Sub
Sub Form_Unload(Cancel As Integer)
On Error GoTo Form_Unload_Err
If CancelYes <> True Then
If ParentFormIsOpen() Then Forms![Employees1]!ToggleLink = False
If Me.TTotal_Score <> "" Then
Dim RaRound
Checkme = True
RaRound = DCount("[Initials]", "Inbound", "[Initials] = [Forms]![Inbound]![Initials]")
If [Forms]![Inbound]![RRound] <> "" Then
Else
If RaRound = "1" Then
[Forms]![Inbound]![RRound] = "1"
Else
[Forms]![Inbound]![RRound] = RaRound
End If
End If
End If
Else
'MsgBox ("This will stop it from closing")
DoCmd.CancelEvent
CancelYes = False
End If
Form_Unload_Exit:
Exit Sub
Form_Unload_Err:
MsgBox ("Not ME") 'Error$
Resume Form_Unload_Exit
End Sub
Option Compare Database
Select Case MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?")
Case Is = vbYes
'MsgBox "Yes"
DoCmd.RunCommand acCmdSaveRecord
Case Is = vbNo
'MsgBox "No"
DoCmd.RunCommand acCmdUndo
CancelYes = False
Case Is = vbCancel
'MsgBox "Cancel"
CancelYes = True
'Do nothing
End Select
End Sub
Sub Form_Unload(Cancel As Integer)
On Error GoTo Form_Unload_Err
If CancelYes <> True Then
If ParentFormIsOpen() Then Forms![Employees1]!ToggleLink = False
If Me.TTotal_Score <> "" Then
Dim RaRound
Checkme = True
RaRound = DCount("[Initials]", "Inbound", "[Initials] = [Forms]![Inbound]![Initials]")
If [Forms]![Inbound]![RRound] <> "" Then
Else
If RaRound = "1" Then
[Forms]![Inbound]![RRound] = "1"
Else
[Forms]![Inbound]![RRound] = RaRound
End If
End If
End If
Else
'MsgBox ("This will stop it from closing")
DoCmd.CancelEvent
CancelYes = False
End If
Form_Unload_Exit:
Exit Sub
Form_Unload_Err:
MsgBox ("Not ME") 'Error$
Resume Form_Unload_Exit
End Sub
Dim Checkme 'Checks to see if it is checking to save from user input or internal changes
Dim CancelYes
Private Sub Form_BeforeUpdate(Cancel As Integer)
Checkme = True
End Sub
Sub Form_Unload(Cancel As Integer)
On Error GoTo Form_Unload_Err
If Checkme = True Then
Dim strMsg As String
strMsg = "Data has changed."
strMsg = strMsg & " Do you wish to save the changes?" & Chr(13)
strMsg = strMsg & "Click 'Yes' to Save or 'No' to Discard the changes."
Select Case MsgBox(strMsg, vbQuestion + vbYesNoCancel, "Save Record?")
Case Is = vbYes
'MsgBox "Yes"
'do nothing
Case Is = vbNo
'MsgBox "No"
DoCmd.RunCommand acCmdUndo
CancelYes = False
Case Is = vbCancel
'MsgBox "Cancel"
CancelYes = True
End Select
End If
If CancelYes <> True Then
If ParentFormIsOpen() Then Forms![Employees1]!ToggleLink = False
Else
'MsgBox ("This will stop it from closing")
DoCmd.CancelEvent
CancelYes = False
End If
Form_Unload_Exit:
Exit Sub
Form_Unload_Err:
MsgBox Error$
Resume Form_Unload_Exit
End Sub