SendObject Command Freezes if user cancels

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • plaskettm
    New Member
    • Jun 2010
    • 3

    #1

    SendObject Command Freezes if user cancels

    I'm rather new to writing VB, well actually about 3 weeks, so please go easy.

    I'm using Office 2003 and have the following code in an Access data base:

    Code:
    Private Sub Command126_click()
    On Error GoTo Err_Command126_click
    
            Dim stDocName As String
            stDocName = "Ideas report - current record"
            DoCmd.SendObject acReport, stDocName, acFormatSNP, , , , "The attached initiative log may be of interest to you", "Title: " & Me.Title, N
    
    Err_Command126_click:
        MsgBox Err.Description
        Resume Exit_Command126_Click
    
    Exit_Command126_Click:
        Exit Sub
    
    End Sub
    This works absolutely fine and generates an e-mail with attachment. If the user decides not to send the e-mail and cancel (i.e. close e-mail message without saving) it returns to the original form - fine.

    However, if I amend Start-up options not to Display Database Window. The same function generates the below message if the operator cancels the e-mail.

    "The Send Object was Cancelled"
    "You used a method of DoCmd object to carry out an action in VB, but then clicked cancel in the dialog box"

    The form now locks and can only be exitted using CTRL+ALT+DEL

    I've read lots of posts about error handling and Err 2501, but the error appears to be happening before it gets to the Error handling.

    Please help I've been stuck for 6 hours now!
    Last edited by MMcCarthy; Jun 11 '10, 06:12 PM. Reason: Added [CODE] tags to your post, see # icon in posting window
  • MMcCarthy
    Recognized Expert MVP
    • Aug 2006
    • 14387

    #2
    From what I can understand this can happen if your form is set as popup. For some reason this command treats the form as modal. Set the form behavior to normal and see if that solves your problem.

    Comment

    • plaskettm
      New Member
      • Jun 2010
      • 3

      #3
      Changed form to Pop-up = No and the error no longer occurs. Brilliant, many thanks for your help

      Comment

      • MMcCarthy
        Recognized Expert MVP
        • Aug 2006
        • 14387

        #4
        You're welcome :)

        Comment

        Working...