Solved

Continuation Access Freezes with email is not sent on second iteration

Posted on 2016-08-31
3
60 Views
Last Modified: 2016-09-03
Dear Experts,

This is a follow on question to the one posted here:
https://www.experts-exchange.com/questions/28966302/Access-freezes-when-user-does-not-send-email.html

Seems that when the user attempts to send an email but closes the email dialogue box the first time no problem! This was the initial fix I was looking for. However, if the user (an this happened) attempts to send an email (once and the closes) and then again attempts to send an email then closes the dialogue box again I get the same error and the application freezes.

In fact, the user sends an email successfully then attempts send another one but closes the dialogue box the application freezes. So for whatever reason the error capture works the first time but not subsequent times. In fact, I pressed on the onclick event, then close the mail dialogue box without sending. Then I close the form to see if this would reset things but when I attempted to send another email message but instead closed the mail MS outlook dialogue box the application once again freezes.

I must need to 'reset' something after the first attempt but not certain what that needs to be. Attached are screenshots of the errors I am getting.

When i close the ms outlook dialogue box for the second time
When i close the ms outlook dialogue box for the second time
When I try to close the application after the error message
When I try to close the application after the error message
0
Comment
Question by:shogun5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
bfuchs earned 500 total points
ID: 41778741
I use error trapper like below w/o problems

On Error GoTo SendEmailErr

    DoCmd.SendObject , , , sEmail, , , sType & "(s) " & sAppDen & ". (Testing)", s, True
SendEmailExit:
    Exit Sub
    
SendEmailErr:
If Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume SendEmailExit
End If

Open in new window

0
 

Author Comment

by:shogun5
ID: 41778931
Yeah....I think I am doing this right. If you look at the link above I used the code provided in the previous discussion block:

Public Sub SendEmail(pName As String)

  On Local Error GoTo LocalError
              
  Dim School As String
  Dim mailto As String
  Dim ccto As String
  Dim bccto As String
  Dim TeacherName As String
  Dim mailsub As String
  
  School = Nz(DLookup("tblSettingsSchool", "tblSettings"), 0)
  TeacherName = Nz(DLookup("teacherName", "tblTeacher"), 0)
  mailto = Me.studentParentEmail
  ccto = ""
  bccto = ""
  mailsub = "Recent Student Report from " & TeacherName & " at " & School
  emailmsg = _
    "Hello " & pName & "!" & vbNewLine & vbNewLine & _
    "Please find your child's student report from " & TeacherName & " at " & School & " attached!" & vbNewLine & vbNewLine & _
    "Thank you!"
  
  DoCmd.SetWarnings (False)
  DoCmd.OpenReport "rptStudentReport", acViewPreview, , "[studentID] = '" & [studentID] & "'"
  DoCmd.SendObject acSendReport, , acFormatPDF, mailto, ccto, bccto, mailsub, emailmsg, True
  DoCmd.Close acReport, "rptStudentReport", acSaveNo
  DoCmd.SetWarnings (True)
  Exit Sub
  
ProcExit:
  DoCmd.Close acReport, "rptStudentReport", acSaveNo
  DoCmd.SetWarnings (True)
  Exit Sub
  
LocalError:
    If Err.Number = 2501 Then
        Resume Next
    Else
        MsgBox Err.Description
        Resume ProcExit
    End If
        
End Sub

Private Sub cmdEmailParent_Click()
  
  Dim pName As String
  
  pName = InputBox("Enter the parent's name", "SEND EMAIL TO PARENT")
  If pName <> vbNullString Then
    SendEmail pName
  End If
         
End Sub

Open in new window


And even with I can the error ONLY on the second and subseqent cancellations. If I close the MS Outlook dialogue box the first time the error is trapped and all is good. But if I try it again then the application freezes. There must be a 'reset' somehow so the trapping works over and over again.
0
 

Author Closing Comment

by:shogun5
ID: 41782815
Thanks! So you the trap works but in this case the solution was actually to take the form out of popup mode and keep modal. Once I did that the erorr when away on the second and subsequnt cancellations. Thanks again!
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question