Mod Does Not Work In Access 2007

K

Kenny G

Hello,

Just converted by Access 2003 DB into Access 2007. All the code worked up
until I tried to run the code for this module (see attached). I am now
getting the message "Type Mismatch". Is there something that has changed in
2007 that I don't know about.

I appreciate your assistance.

Option Compare Database
Option Explicit

Sub SendMessages(Optional AttachmentPath)


Dim MyDB As Database
Dim MyRS As Recordset
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim ToAddress As String
Dim CCAddress As String
Dim sBody As String
'Dim BCCAddress As String

Set MyDB = CurrentDb
Set MyRS = MyDB.OpenRecordset("tblNonCompIPOPAllStandards")
MyRS.MoveFirst

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")

Do Until MyRS.EOF
' Create the e-mail message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)



With objOutlookMsg
' Add the To recipients to the e-mail message.
If Len(Forms!frmMail!txtToAddress & vbNullString) > 0 Then
Set objOutlookRecip = .Recipients.Add(Forms!frmMail!txtToAddress)
objOutlookRecip.Type = olTo
End If

' Add the Cc recipients to the e-mail message.
If Len(Forms!frmMail!txtCCAddress & vbNullString) > 0 Then
Set objOutlookRecip = .Recipients.Add(Forms!frmMail!txtCCAddress)
objOutlookRecip.Type = olCC
End If

' Add the BCC recipients to the e-mail message.
'If Len(Forms!frmMail!txtBCCAddress & vbNullString) > 0 Then
'Set objOutlookRecip = .Recipients.Add(Forms!frmMail!txtBCCAddress)
'objOutlookRecip.Type = olBCC
'End If

sBody = "Attached are the results of the tracer survey performed on
your unit.<br>"
sBody = sBody & "Please review report and note the identified
areas requiring improvement.<br><br>"
sBody = sBody & "Necessary corrective actions for identified
deficiencies should be implemented<br>"
sBody = sBody & "in your area. We will be doing a follow up
survey to evaluate changes.<br><br>"
sBody = sBody & "Please feel free to contact me or Kimberly
Gonzalez should you have any questions<br>"
sBody = sBody & "or need assistance with patient safety or Joint
Commission issues.<br><br>"
sBody = sBody & "Thank you.<br><br><br>"
sBody = sBody & "PV/KG<br>"


' Set the Subject, the Body, and the Importance of the e-mail message.
.Subject = "Tracer Survey Report!"
.Importance = olImportanceHigh 'High importance
.HTMLBody = sBody


'Add the attachment to the e-mail message.
Set objOutlookAttach = .Attachments.Add("S:\Quality & Process
Improvement\QPI\JCAHO PreSurvey Tool\Documents\CurrentPreSurveyReport.snp")



' Resolve the name of each Recipient.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next

.Display
'.Send
End With
MyRS.MoveNext
Loop

Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub
 
R

Ray

I ran into a similar situation. A variable declared as type Folder worked
fine in Access 2003, but generated a type mismatch error in Access 2007.
When I removed the type declaration...

change
Dim F As Folder
to just
Dim F

the problem went away. Using the untyped variable works in both Access 2003
and Access 2007.

Ray
 
R

Ray

Do you know which is the offending variable/line of code? If not, set a
break and step through line by line. That would narrow the list of potential
issues considerably.
 
K

Kenny G

Ray,

Finally got it. I was doing an export as .snp. The snapshotviewer can no
longer be exported in Access 2007.

I changed the .snp to pdf (now supported) added a reference to PDF's. Works
great now.

Thanks,
 

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