Send Objects Freezes Access on Cancel

C

CJ

Hi Groupies

I am working with code to send emails to multiple recipients
If I push the button to send the email and then if I cancel out of Outlook
and return to Access, my database freezes if I push the button to send the
email again.

This problem happens with either Access 2003 or 2007. I have Outlook 2007
and a Vista machine.

My complete code is as follows:

Option Compare Database
Option Explicit

Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click

' ©Arvin Meyer 1999-2004
' Permission to use is granted if copyright notice is left intact.
' Permisssion is denied for use with unsolicited commercial email

Dim strContacts As String
Dim strSubject As String
Dim strMessage As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb

strContacts = Me.txtSelected & vbNullString
strSubject = Me.txtSubject & vbNullString
strMessage = Me.txtMessage & vbNullString
DoCmd.SendObject acSendNoObject, , acFormatHTML, To:=strContacts,
Subject:=strSubject, MessageText:=strMessage

Exit_cmdSendEmail_Click:

Set rst = Nothing
Set db = Nothing

Exit Sub

Err_cmdSendEmail_Click:
MsgBox Err.Description
Resume Exit_cmdSendEmail_Click

End Sub

Private Sub lstContacts_Click()
Dim varItem As Variant
Dim strList As String

With Me!lstContacts
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
Me!txtSelected = strList
End If
End With
End Sub


Thanks for having a look at this for me.
 
A

Arvin Meyer [MVP]

If it's an Access problem, you can find out, by first opening another form,
then closing it. If it works OK, it probably isn't an Access problem. Now
close the email form and reopen it. Push the button. Does it freeze? Try
leaving Outlook open, does it freeze Access when pushing the button? Now, if
possible try it on a different machine, say an XP machine.
 
C

CJ

Hi Arvin, thanks for popping in.

It turns out that it must be a machine issue. The code works beautifully on
my Vista tower, just the laptop is causing this grief. They are both
supposed to be configured the same.....heh heh

Thanks for the code!!!!!!!!

--
Thanks for taking the time!

CJ
---------------------------------------------------------
Know thyself, know thy limits....know thy newsgroups!
Arvin Meyer said:
If it's an Access problem, you can find out, by first opening another
form, then closing it. If it works OK, it probably isn't an Access
problem. Now close the email form and reopen it. Push the button. Does it
freeze? Try leaving Outlook open, does it freeze Access when pushing the
button? Now, if possible try it on a different machine, say an XP machine.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
D

Dale Fye

When you cancel out of the email send, are you getting an error message?

I generally trap for the "SendObject cancelled" error (2501) and handle
those depending on my business rules.

Is Outlook already open when you run the code, or are you doing so with
Outlook closed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top