Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendObject Cancelled Error Message

Status
Not open for further replies.

jbento

Technical User
Jul 20, 2001
573
US
All,
I have the following code below that is behind a command button on a form. Once the email comes up and they decide not to send the email and close the outlook message, it will give an error message.

I would like to suppress that error message by using the following:

DoCmd.SetWarnings True
DoCmd.SetWarnings False

but it is not working. The DoCmd.SetWarnings True is before the SendObject code and the DoCmd.SetWarnings False is after the SendObject code.

Does anyone know why this wouldn't work?

Please help.

Thank you all very much.

Dim strSubject As String

strSubject = Me.title

DoCmd.SendObject acSendReport, "rpt_PAF_GenUserEmail", acFormatSNP, "", "email@anywhere.com", , strSubject, "Subject Line Text Here.", False

The above code is behind a command button on a switchboard.

I have a table that has a date field. It is on a form called frmTest. I would like to be able to include that date field on the strSubject line.

Something like this:

strSubject = The email is sent as of [Forms]![frmTest]![date].Value

I know that is wrong. Can someone help me with this?

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Hi

To get rid of the error message:

Dim strSubject As String
On error GoTo Error_Trap
strSubject = Me.title

DoCmd.SendObject acSendReport, "rpt_PAF_GenUserEmail", acFormatSNP, "", "email@anywhere.com", , strSubject, "Subject Line Text Here.", False

Exit_MySub:
Exit Sub
Error_Trap:
If err.number = 2501 then
resume Exit_MySub
Else
msgBox "error " & err.number & " " & err.description
resume exiy_mySub
End If

to get the date in the subject line, assuming frmTest is open at the time:

strSubject = "The email is sent as of " & [Forms]![frmTest]![date]

if frmTest is the form containing the button to send the email:

strSubject = "The email is sent as of " & Me![date]

And finally Date is a reserved word in Access (date function Date()), DO NOT USE IT OR ANY OTHER RESERVED WORD AS A COLUMN NAME, it will end in all kinds of problems down the line


Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks Ken.

I actually figured the date thing out with the following:

strSubject = "The GEWG Email is being sent as of:" & " " & Forms!frm_test!date & ""

I just tried your error trapping method, and it works like a charm.

I will also take your advice on not using date as a field name.

I have one last question for you.

If I have a field called dueDate that is located on a form. The date in that field is say 3/15/04 and I wanted the database to automatically send an email to recipients if it is 10 days before that date.

How would I do that? Any ideas?

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Hi

The word automatically fills me with dread

Be realistic do you plan to leave your PC switched on 24/7?

You need to either have the database running 24/7 and use the time control to periodically (say daily) run a query which checks for any items to be EMailed, or you could make it part of your start up routine in your database

Before anyone can give a sensible answer to this question you need to think about the level of service you are trying to provide to this problem, would a daily check surfice, does it have to check once a second ?





Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I'm sorry I didn't give enough information.

This would only occur once the database is opened and on an OnOpen Event of a specific report. I would have a timer set to open and close that report to generate the automatic email.

That report would be connected to a query that would capture all records that is populated by a dueDate.

Is that enough information?

You had me laughing about the 24/7 thing:):):)

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top