473,618 Members | 3,044 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Emailing a Report - Error if mail is cancelled

17 New Member
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 2502
NeoPa
32,566 Recognized Expert Moderator MVP
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 Recognized Expert Top Contributor
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,566 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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,566 Recognized Expert Moderator MVP
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
1912
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 run. Now I have a number of tables in this database...looking like this: editorial editorialdate, editorialname, editorialcomments press
6
1774
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 able to select a report's radio button and click one of the four command buttons. Currently, Preview and Print work. But the Reports have parameters in their queries. I'm prompted for the values for the Print and Preview buttons, but for some...
4
9655
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 Membership Head of Families", vbInformation Cancel = True
1
2603
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 easily read file... any help is greatly appreciated. thanks.. here is my current code.. and also some info on the report is populated by the current record i am on in the form... On Error GoTo cmdEMailReport_Click_Err Dim strMsg As String,...
0
8153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8653
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8595
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8304
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8455
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7126
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6101
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2587
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.