Kayleigh
Member
- Local time
- Today, 08:25
- Joined
- Sep 24, 2020
- Messages
- 706
Hi I have some simple code for the save procedure of a form. I would only like the confirm message to display if form = dirty but it is always displaying even when I open and immediately close. Is there any other way to do this?
Here is my code:
Here is my code:
Code:
Private Sub cmdClose_Click()
Dim intPressed As Variant
If Me.Dirty = False Then
DoCmd.Close acForm, Me.Name
If IsFormLoaded("frmSessions") Then
Forms!frmSessions.Requery
Forms!frmSessions.Visible = True
End If
Exit Sub
End If
If (Me.NewRecord = False) Then
intPressed = MsgBox("Do you want to save changes?", vbYesNo + vbQuestion)
If intPressed = 7 Then
Me.Undo
DoCmd.Close acForm, Me.Name
If IsFormLoaded("frmSessions") Then Forms!frmSessions.Visible = True
Exit Sub
Else
DoCmd.Save acForm, Me.Name
DoCmd.Close acForm, Me.Name
If IsFormLoaded("frmSessions") Then
Forms!frmSessions.Requery
Forms!frmSessions.Visible = True
End If
Exit Sub
End If
Else
DoCmd.Save acForm, Me.Name
DoCmd.Close acForm, Me.Name
If IsFormLoaded("frmSessions") Then
Forms!frmSessions.Requery
Forms!frmSessions.Visible = True
End If
End If
End Sub