Object not set or with block error

T

Tammy

Can someone look at this code and tell me why I would be
receiving an "Object variable or with block not set"
error (error message may not be quite word for word). I
know what to look for (I believe I do anyway) - but am
just not finding it! The message is getting out - or at
least the security message box is popping up. I get the
message right after I click the "yes" key. I am guessing
it has something to do with the placement - I guess - of
my "set oApp = nothing" and "oApp.quit" statements (group
of statements)! Thanks for any help!

Private Sub cmdOKEmail_Click()
On Error GoTo Err_cmdOKEmail_Click

Dim db As Database
Dim objOutlook As Outlook.Application
Dim objMessage As MailItem
Dim strNote As String
Dim strFromAuthor As String
Dim strBlindCopy As String
Dim strPath As String
Dim varItem As Variant
Dim recSupers As DAO.Recordset

Set db = CurrentDb()
Set recSupers = db.OpenRecordset("Supers", dbOpenDynaset)
Set objOutlook = Outlook.Application
Set objMessage = objOutlook.CreateItem(olMailItem)

strBlindCopy = "(e-mail address removed)"
strPath = "C:/My Documents/Saved SOP's/"
strNote = "Dear" & " " & recSupers("Employee") & _
vbCrLf & vbCrLf & _
Me![txtMessage] & _
vbCrLf & vbCrLf & _
Me![Author]

msg1:
With objMessage
.To = Me![cmbSupers]
.BCC = strBlindCopy
.Attachments.Add ("C:\SavedSOPs\" & Me![SOP Name]
& ".doc")
.Subject = "New SOP" & Me![SOP Name]
.Body = strNote
.Send
End With

Set recSupers = Nothing
recSupers.Close
Set objOutlook = Nothing
Set objMessage = Nothing
objOutlook.Quit
objMessage.Quit

Me![cmdNew].Visible = True

Exit_cmdOKEmail_Click:
Exit Sub

Err_cmdOKEmail_Click:
MsgBox Err.Description
Resume Exit_cmdOKEmail_Click
End Sub
 

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