I introduced a YesNoCancel button on the before update event of the form. So now the user gets prompted if he wants to save the record or not.
The form has a subform so if the user enters data in the main form and then clicks the subform it gets the YesNoCancel msg and decides what he wants to do.
The problem lies in the save button on the main form. When he clicks it the msg box pops up twice. Why is that?
code for save button:
Code for the msgbox:
The form has a subform so if the user enters data in the main form and then clicks the subform it gets the YesNoCancel msg and decides what he wants to do.
The problem lies in the save button on the main form. When he clicks it the msg box pops up twice. Why is that?
code for save button:
Code:
Private Sub SaverecordOtherOperations_Click()
On Error GoTo Err_SaverecordOtherOperations_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
[Stop time] = Time
[TotalTime] = Diff2Dates("hns", [Start time], [Stop time], 0)
DoCmd.GoToRecord , , acNext
Exit_SaverecordOtherOperations_Click:
Exit Sub
Err_SaverecordOtherOperations_Click:
MsgBox Err.Description
Resume Exit_SaverecordOtherOperations_Click
End Sub
Code:
rivate Sub Form_BeforeUpdate(Cancel As Integer)
Select Case MsgBox("Salvati Inregistrarea?", vbYesNoCancel, "Atentie!!")
Case vbYes
'code
Save = True
[Stop time] = Time
[TotalTime] = Diff2Dates("hns", [Start time], [Stop time], 0)
Case vbNo
'code
Me.Undo
Case vbCancel
'code
Cancel = True
End Select
End Sub
Comment