C
Clinton
Hallo,
I use the following code for saving a record. A botton for saving and a
confirmation in the before update event. Idea is that the user has to
confirm the change/save. The below code works fine. The save triggers the
before update.
But now i actualy have 2 save code (save button and beforeupdate (triggerd
by the save button)). Can i combine this so only the before update save
action is used or moving it to another place. Tried various combinations but
can't find another way that gets rid of the cmdSave save action...
--code start 1--
Private Sub CmdSave_Click()
On Error GoTo Err_CmdSave_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_CmdSave_Click:
Exit Sub
Err_CmdSave_Click:
MsgBox Err.Description
Resume Exit_CmdSave_Click
End Sub
--code end 1--
--code start2--
Private Sub Form_BeforeUpdate(Cancel As Integer)
Msg = "Update changes?"
Style = vbYesNo + vbQuestion
Title = "Customers"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
'close
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
--code end2--
Thanx in advance for any tips.
Regards
I use the following code for saving a record. A botton for saving and a
confirmation in the before update event. Idea is that the user has to
confirm the change/save. The below code works fine. The save triggers the
before update.
But now i actualy have 2 save code (save button and beforeupdate (triggerd
by the save button)). Can i combine this so only the before update save
action is used or moving it to another place. Tried various combinations but
can't find another way that gets rid of the cmdSave save action...
--code start 1--
Private Sub CmdSave_Click()
On Error GoTo Err_CmdSave_Click
DoCmd.RunCommand acCmdSaveRecord
Exit_CmdSave_Click:
Exit Sub
Err_CmdSave_Click:
MsgBox Err.Description
Resume Exit_CmdSave_Click
End Sub
--code end 1--
--code start2--
Private Sub Form_BeforeUpdate(Cancel As Integer)
Msg = "Update changes?"
Style = vbYesNo + vbQuestion
Title = "Customers"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
'close
Else
DoCmd.RunCommand acCmdUndo
End If
End Sub
--code end2--
Thanx in advance for any tips.
Regards