save button notification (1 Viewer)

Ravi Kumar

Registered User.
Local time
Tomorrow, 04:13
Joined
Aug 22, 2019
Messages
162
form my save a button I have written the below to show a notification & then save code but it is not working , pls suggest me the correct code:
Private Sub cmdsave_click()
If Me.Dirty = True Then
If MsgBox("Do you want to save the changes for this record?", _
vbYesNo + vbQuestion, "Save Changes?") = vbNo Then
Me.Undo
End If
End If
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:43
Joined
Oct 29, 2018
Messages
21,358
Hi. What does "is not working" mean? What is actually happening when you click the button?
 

Ravi Kumar

Registered User.
Local time
Tomorrow, 04:13
Joined
Aug 22, 2019
Messages
162
it is not saving any changes & not displaying new record..
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:43
Joined
May 7, 2009
Messages
19,169
Code:
Private Sub cmdsave_click()
   If Me.Dirty = True Then
      If MsgBox("Do you want to save the changes for this record?", _
         vbYesNo + vbQuestion, "Save Changes?") = vbNo Then
         Me.Undo
[COLOR="Purple"]      Else
         Me.Dirty = False
[/COLOR]      End If
   End If
End Sub
 

Ravi Kumar

Registered User.
Local time
Tomorrow, 04:13
Joined
Aug 22, 2019
Messages
162
dear sir ,
it is saving but it is showing new record after saving,

Private Sub cmdsaveandnew_Click()
If Me.Dirty = True Then
If MsgBox("Do you want to save the changes for this record?", _
vbYesNo + vbQuestion, "Save Changes?") = vbNo Then
Me.Undo
Else
Me.Dirty = False
End If
End If
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 22:43
Joined
Sep 21, 2011
Messages
14,048
PMFJI,

I expect you will be posting a lot of code in the future.

Please consider using the code tags # to show your code with decent indentation.

Just like arnelgp posted back to you.

That way you help others to help you.

dear sir ,
it is saving but it is showing new record after saving,

Private Sub cmdsaveandnew_Click()
If Me.Dirty = True Then
If MsgBox("Do you want to save the changes for this record?", _
vbYesNo + vbQuestion, "Save Changes?") = vbNo Then
Me.Undo
Else
Me.Dirty = False
End If
End If
End Sub
 

missinglinq

AWF VIP
Local time
Today, 18:43
Joined
Jun 20, 2003
Messages
6,423
First, you complain that it is not displaying a new record...then you complain that it is displaying a new Record...which do you want?

If you want it to move to a new Record...you need to tell Access to go to a new Record:

DoCmd.GoToRecord , , acNewRec

Linq ;0)>
 

Users who are viewing this thread

Top Bottom