First off, I am still extremely new to VBA and access in general, so please bare with me. Below is a code I am using to send a specific workorder to a technician. The problem I am having is if you back out before sending it, access gives users the ability to debug my code. I know I need to add an error handler but I am clueless on how to do it. Any help is appreciated. Thank you!
On a side not, I would really like my report to be populated with the company name as the subject automatically but haven't been able to get it to work for some reason. That's more of a secondary concern though. My field for company name is CompanyName.
Private Sub Email_Workorder_Click()
Dim strDocName As String
Dim strWhere As String
strDocName = "Workorders"
If Me.Dirty Then Me.Dirty = False
strWhere = "[WorkorderID]=" & Me!WorkorderID
DoCmd.OpenReport strDocName, acPreview, , strWhere
DoCmd.SendObject acSendReport, "Workorders", acFormatPDF, , "CC", "BCC"