
Thanks for any help in advance!
Code:
Private Sub Command37_Click()
Dim oMainDoc As Word.Document
Dim oSel As Word.Selection
Dim sDBPath As String
Set oMainDoc = oApp.Documents.Open("z:\HIPAA\Breach Notification\Template Letter")
oApp.Visible = True
With oMainDoc.MailMerge
.MainDocumentType = wdFormLetters
sDBPath = "z:\HIPAA\Breach Notification\Breach Notification.mdb"
strCriteria = [Forms]![All Breach Records]![New ID]
.OpenDataSource Name:=sDBPath, _
SQLStatement:="SELECT * FROM [Spreadsheet Breach Info Query]" & _
"WHERE [Spreadsheet Breach Info Query].[New ID] IN(" & strCriteria & ");"
End With
With oMainDoc
.MailMerge.Destination = wdSendToNewDocument
.MailMerge.Execute
End With
oApp.Activate
oApp.Documents.Parent.Visible = True
oApp.Documents(2).Close wdDoNotSaveChanges
oApp.Application.WindowState = 1
oApp.ActiveWindow.WindowState = 1
On Error GoTo err_Command37_click
Dim strRecipient As String
Dim strRecipient2 As String
Dim strSubject As String
Dim strMessage As String
strRecipient = "0" & Me.Store_Number & "-US-RX MANAGER"
strRecipient2 = Me.Market_Manager_Name & " " & Me.market_manager_last_name
strSubject = "HIPAA Breach Notification"
strMessage = "Test" & vbCrLf & vbCrLf
DoCmd.SendObject acSendNoObject, , , strRecipient, strRecipient2, , strSubject, strMessage
exit_Command37_click:
Exit Sub
err_Command37_click:
If Err.Number = 2501 Then
MsgBox "Email was canceled!", vbInformation
Else
MsgBox Err.Number & "; " & Err.Description
End If
Resume exit_Command37_click
End Sub