The code attached below is used to run 2 append queries from a form when a button is clicked. I have switched the warnings off and provided the user the chance to cancel the append after the button is clicked. However I would like to inform the user whether the record to be appended has infact been appended or whether it was unsuccessful because the record already exists. Is this possible without reverting to the standard append messages?
Private Sub AppendBtn_Click()
On Error GoTo Err_AppendBtn_Click
Dim stDocName As String
Dim stDocNameB As String
'Turns off the Access warning messages
DoCmd.Hourglass True
DoCmd.SetWarnings False
'Gives the user the chance to cancel procedure
If MsgBox("Clicking YES will save this Record!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") = vbYes Then
'Appends the data from the form to the table
stDocName = "AppendClassesPart2"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocNameB = "AppendStudentsPart2"
DoCmd.OpenQuery stDocNameB, acNormal, acEdit
MsgBox ("Record Saved")
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
Else
Me.Undo
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
End If
Exit_AppendBtn_Click:
Exit Sub
Err_AppendBtn_Click:
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_AppendBtn_Click
End Sub
Private Sub AppendBtn_Click()
On Error GoTo Err_AppendBtn_Click
Dim stDocName As String
Dim stDocNameB As String
'Turns off the Access warning messages
DoCmd.Hourglass True
DoCmd.SetWarnings False
'Gives the user the chance to cancel procedure
If MsgBox("Clicking YES will save this Record!" _
& vbCrLf & vbCrLf & "Do you wish to commit these changes?", _
vbYesNo, "Do You Require These Changes Made...") = vbYes Then
'Appends the data from the form to the table
stDocName = "AppendClassesPart2"
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocNameB = "AppendStudentsPart2"
DoCmd.OpenQuery stDocNameB, acNormal, acEdit
MsgBox ("Record Saved")
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
Else
Me.Undo
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
End If
Exit_AppendBtn_Click:
Exit Sub
Err_AppendBtn_Click:
'Turns the Access warning messages back on
DoCmd.Hourglass False
DoCmd.SetWarnings True
MsgBox Err.Description
Resume Exit_AppendBtn_Click
End Sub