473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Emailing a Report - Error if mail is cancelled

17
Hi everyone!
Could someone help me with this, please?
I run Access2000 on XP

Have created a Report.
Have placed a button on a form to email the report
Works fine - email is generated, ready to input the To address & send. However If I decide not to send it afterall and (X) close the email this is what happens:
* I get a dB error message (1) which I can close with an OK,
* then it runs the button's error message (Code line 19) ,
* then it locks up the exiting of the whole database with another error message(3) and I have to Ctr/Alt/Del to get out....I can stay in the database and roam about to any other area, form , eport etc, can even again generate the same report in email and sucessfully send it, but I can't Quit the DB.

This is the code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub MAILRPT_Click()
  2.   On Error GoTo Err_MAILRPT_Click
  3.  
  4.   DoCmd.SendObject _
  5.     acSendReport, _
  6.     "rptCTStatus", _
  7.     acFormatRTF, _
  8.     , _
  9.     , _
  10.     , _
  11.     "Status Report", _
  12.     "Attached is the Status Report Do not reply to this Automated Email ", _
  13.     True
  14.  
  15.   Exit_MAILRPT_Click:
  16.   Exit Sub
  17.  
  18.   Err_MAILRPT_Click:
  19.   MsgBox "Send of Report is cancelled!"
  20.  
  21.   Resume Exit_MAILRPT_Click
  22. End Sub

Message 1
: <Title: Database Name> - the SendObject action was cancelled. You used a method of the DoCmd Object to carry out an action in Visual Basic, but then clicked Cancel in a Dialog Box...."

Message3: "You can' exit the <Database Name> now. If you're running a Visual Basic Module that is using OLE or DDE, you may need to interrupt the module"

So my question: How do I amend this code to allow for a user changing their mind and cancelled the sending of the email, and preventing the messges 1 and 3??

Thanks! Hope you can help and hopefully simple to fix!

Cheers
AMBLY
Jun 19 '07 #1
5 2488
NeoPa
32,556 Expert Mod 16PB
This sounds like a bug in the Access (or at least library) code itself. I can't think of anything you can do to avoid this other than maybe exploring other methods of sending the email.
Your error handling code is working exactly as expected. I'm sorry. Maybe someone else may have some further light to throw on this matter.
Jul 4 '07 #2
puppydogbuddy
1,923 Expert 1GB
This sounds like a bug in the Access (or at least library) code itself. I can't think of anything you can do to avoid this other than maybe exploring other methods of sending the email.
Your error handling code is working exactly as expected. I'm sorry. Maybe someone else may have some further light to throw on this matter.

One alternative you have is to do away with the X button on your form and create your own custom close button.

To do away with the X button, invoke the form's property sheet in design view and set the Close Button property to No. Then create your own close button with code similar to the following:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdClose_Click
  2. If Me.Dirty Then
  3.         Me.Undo
  4. End If
  5. DoCmd.Close
  6. End Sub
  7.  
Jul 4 '07 #3
NeoPa
32,556 Expert Mod 16PB
If that works for you, you can probably simplify the code by just adding :
Expand|Select|Wrap|Line Numbers
  1. If Me.Dirty Then Me.Undo
after your line #18 of your posted code.
Jul 5 '07 #4
Lysander
344 Expert 100+
So my question: How do I amend this code to allow for a user changing their mind and cancelled the sending of the email, and preventing the messges 1 and 3??

Thanks! Hope you can help and hopefully simple to fix!

Cheers
AMBLY
You can ask the user to supply the addresses before they initiate the sendobject and then change the true to false, which should send the email without giving them the option to cancel.
Jul 5 '07 #5
NeoPa
32,556 Expert Mod 16PB
You can ask the user to supply the addresses before they initiate the sendobject and then change the true to false, which should send the email without giving them the option to cancel.
Thinking outside the box. I like that answer :)
Jul 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: paul814 | last post by:
I've been working on this for some time now and have gotten nowhere...hoping someone here can help. I want to take and email all records in a database for the current date when this php page is...
6
by: ladybug76 | last post by:
Hello. Okay, so I have an Option Group with 6 reports on the Right hand side of a form. On the left, I have 4 command buttons. 1) Preview 2) Print 3) Save off 4) Email. I want the user to be...
4
by: Phil Stanton | last post by:
I am opening a report (in Preview) from a menu system I use the following code if there is no data in a report Private Sub Report_NoData(Cancel As Integer) MsgBox "There are no errors in...
1
by: didacticone | last post by:
i have a database where i am trying to email a report as an attachment, it works fine but since it is an .rtf file the conversion is messy... i was wondering if i can do it as a pdf or some other...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.