A family of Microsoft relational database management systems designed for ease of use.
You need to include error trapping in your procedure:
Private Sub Command25_Click()
On Error GoTo ErrorHandler
Me.Dirty = False
DoCmd.OpenReport "nonconformity", acViewPreview, , "[nonconformid] =" & Me.NonConformID
DoCmd.SendObject acSendReport, , acFormatPDF, Forms![non conformity]![Contact]
DoCmd.Close acReport, "NonConformity", acSaveNo
MsgBox "Message Sent Successfully."
Cleanup:
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
MsgBox "Email message was Cancelled."
Case Else
MsgBox Err.Number & ": " & Err.Description
End Select
Resume Cleanup
End Sub
Incidentally, do yourself a huge favour, and give your controls meaningful names. You may know today that Command25 is the command button that sends the email, but will you when you need to go back to your application a week or a month from now?