Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Are you sure you want to save?", vbYesNo + vbInformation) = vbYes Then
DoCmd.Save acForm, "frmBPREdit"
MsgBox "Your changes have been saved! ", vbInformation
Check = 1
Else
Exit Sub
MsgBox "No changes have been recorded! ", vbInformation
DoCmd.Close acForm, "frmBPREdit", acSaveNo
End If
End Sub
ASKER
ASKER
ASKER
Option Compare Database
Dim Check As Integer
Private Sub Form_AfterUpdate()
If Check = 1 Then
Dim stDocName As String
DoCmd.SetWarnings False
stDocName = "qryUpdateBPR"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.SetWarnings True
End If
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
If MsgBox("Are you sure you want to save?", vbYesNo + vbInformation) = vbYes Then
DoCmd.Save acForm, "frmBPREdit"
MsgBox "Your changes have been saved! ", vbInformation
Check = 1
Else
Exit Sub
MsgBox "No changes have been recorded! ", vbInformation
DoCmd.Close acForm, "frmBPREdit", acSaveNo
End If
End Sub
Private Sub cmdSave_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub
Private Sub cmdClose_Click()
DoCmd.Close
DoCmd.Close acForm, "frmBPRSearch", acSaveNo
End Sub
Private Sub Form_Load()
Check = 2
End Sub
ASKER
ASKER
ASKER
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
The Save is saving the form design not the data in the form.
The code will only run when there is data to be saved, but a No answer looks as if it is bound to produce an error message because the cancel command has not been issued.