Results 1 to 5 of 5
  1. #1
    matt_wpg is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    20

    EmailDatabaseObject causes error when cancelled

    Hi guys, I have a macro run when a button is pressed to email a pdf of a form. This works great unless the user cancels the email, it will cause an error when the user tries to exit the database. The message says "You can't exit database X right now. If you're running a visual basic module that


    is using OLE or DDE, you may need to interrupt the module."

    Any ideas?

    Thanks in advance!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Did you put in an error trap?

    cant you just use:
    docmd.SendObject....

  3. #3
    matt_wpg is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    20
    Thanks for the reply @ranman256.

    I tried using an error trap and now it is just freezing access completely.
    To be honest, I don't know the differences between the different traps. I will do some research and post if I manage to solve the issue using an error trap.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    the 1st statement after the DIM variables is ON ERROR GOTO name
    then the block after the label is where the code will go and stop when it hits the messagebox.

    Code:
    sub MyRoutine()
    dim x,y
    
    on error goto ErrStop
       'code
    exit sub
    
    ErrStop:
     msgbox err.description,,err
    end sub

  5. #5
    matt_wpg is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2017
    Posts
    20
    Thanks @ranman256! Much appreciated!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 11-26-2013, 09:20 AM
  2. Replies: 2
    Last Post: 08-05-2013, 01:56 PM
  3. Replies: 2
    Last Post: 01-22-2013, 10:39 PM
  4. Error When Event is Cancelled
    By tylerg11 in forum Forms
    Replies: 1
    Last Post: 02-07-2012, 09:48 AM
  5. Replies: 2
    Last Post: 11-02-2009, 10:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums