Discussion Locked
0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do I close a form without saving the record?
6 replies
by peyison
The following code will close the form without saving changes to the current record.
Private Sub cbtClose_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo
DoCmd.Close
End Sub
Hope this helps.
The question was auto-closed by TechRepublic
by it_cowboy
the above is correct, but if the record is not 'dirty' (nothing has been entered in the new record), it will cause a error.
Add the following lines around the code mentioned above...
If Me.Dirty Then
[Enter the above code here]
End If
by it_cowboy
That code should be...
Private Sub cbtClose_Click()
If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo
End If
DoCmd.Close
End Sub
The question was auto-closed by TechRepublic
This question was auto closed due to inactivity
This discussion is closed to new replies.
Trending Software posts
Sort by Trending
1 helpful
1 reply
0 helpful
20 replies
Question Unanswered
How Are Teams Testing AI-Generated Code Before Production?
0 helpful
0 replies
0 helpful
4 replies
Discussion
Is There any Reverse Video Search Tool
0 helpful
8 replies