Solved Trouble with email command

icatterall

New member
Local time
Yesterday, 18:40
Joined
Sep 7, 2023
Messages
5
I have a button that exports a PDF to Outlook. Everything on that end runs perfectly. However, if I choose not to send that email, my database locks up. This is happening on the front end which is locked down. Is there a code that I should put in to stop the macro error due to not sending the email? Thank you for any and all help.
 
Is this a macro or VBA? Provide code or attach db to post.
 
Sorry about that, it is VBA.

Private Sub Command168_Click()
sTo = Me.txt_186
sSubj = "Automated Email of an Observation of " & Me.[FL]
sBody = "Attached is an observation of" & " " & Me.[FL] & ", and it requires your attention."

DoCmd.SendObject acSendReport, "Rpt_MainInstantIncidentEmail", acFormatPDF, sTo, , , sSubj, sBody

End Sub
 
You said it was locked down. Therefore your question has to be in two parts. First, can you even work on the modules of that locked-down front end? Second, when you try to send the mail, do you get an Outlook screen to show you the message and let you send it or not as you choose?
 
@June7 Thank you and I will give that a go.
@The_Doc_Man I do get the pdf file and the message to the Outlook screen. However, let's say that I hit that button mistakenly. If I close out of Outlook without sending it throws an error. This gets me to your other point. I will have to delete the front end, make some changes, and recreate the .accde
 
Use an error handler like:

Should have Option Explicit at top of every module. This will force all variables to be declared.

To include automatically in new module, from the VBA Editor: Tools > Options > check "Require Variable Declaration".
Will have to manully add to existing modules.
This worked really well, thank you!
 

Users who are viewing this thread

Back
Top Bottom