M
meenderingm
I have the following tables AuditTableList whose fiels are: ProviderID,
EmailAddress, DirEmail, OpsDirEmail, OtherEmail1 & OtherEmail2. I also have
a table called Audit Results this table has the data for the report
“LettersToBeSent†that I want to email out as an attached Snapshot Viewer
file. The fields that link these two tables together is called ProviderID.
I have the following code to loop through the recordsent of AuditTableList
and to send out the report to all of the providers in this list. The report
that is sent to each provider should be only for that provider.
******************************************************************************************************************
Option Compare Database
Option Explicit
Sub SeparateEmails()
On Error GoTo Err_SeparateEmails
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim rsGLTable As Recordset
Dim rsCriteria As Recordset
Set db = CurrentDb
Set rsCriteria = db.OpenRecordset("AuditTableList", dbOpenSnapshot)
rsCriteria.MoveFirst
Do Until rsCriteria.EOF
strSQL = "SELECT * FROM Last4AuditResults-AuditedProviders WHERE "
strSQL = strSQL & "[ProviderID] = '" & rsCriteria![ProviderID] & "'"
db.QueryDefs.Delete "NewQuery"
Set qdf = db.CreateQueryDef("NewQuery", strSQL)
DoCmd.SendObject acReport, "Letters-AuditedProviders", "SnapshotFormat(*.
snp)", rsCriteria![EmailAddress], rsCriteria![MedDirEmail], "", "Electronic
Health Record Compliance Policy", "Please See Attached", False, ""
rsCriteria!Emailed = True
rsCriteria.MoveNext
Loop
rsCriteria.Close
Exit_SeparateEmails:
Exit Sub
Err_SeparateEmails:
If Err.Number = 3265 Or Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_SeparateEmails
End If
End Sub
EmailAddress, DirEmail, OpsDirEmail, OtherEmail1 & OtherEmail2. I also have
a table called Audit Results this table has the data for the report
“LettersToBeSent†that I want to email out as an attached Snapshot Viewer
file. The fields that link these two tables together is called ProviderID.
I have the following code to loop through the recordsent of AuditTableList
and to send out the report to all of the providers in this list. The report
that is sent to each provider should be only for that provider.
******************************************************************************************************************
Option Compare Database
Option Explicit
Sub SeparateEmails()
On Error GoTo Err_SeparateEmails
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
Dim rsGLTable As Recordset
Dim rsCriteria As Recordset
Set db = CurrentDb
Set rsCriteria = db.OpenRecordset("AuditTableList", dbOpenSnapshot)
rsCriteria.MoveFirst
Do Until rsCriteria.EOF
strSQL = "SELECT * FROM Last4AuditResults-AuditedProviders WHERE "
strSQL = strSQL & "[ProviderID] = '" & rsCriteria![ProviderID] & "'"
db.QueryDefs.Delete "NewQuery"
Set qdf = db.CreateQueryDef("NewQuery", strSQL)
DoCmd.SendObject acReport, "Letters-AuditedProviders", "SnapshotFormat(*.
snp)", rsCriteria![EmailAddress], rsCriteria![MedDirEmail], "", "Electronic
Health Record Compliance Policy", "Please See Attached", False, ""
rsCriteria!Emailed = True
rsCriteria.MoveNext
Loop
rsCriteria.Close
Exit_SeparateEmails:
Exit Sub
Err_SeparateEmails:
If Err.Number = 3265 Or Err.Number = 2501 Then
Resume Next
Else
MsgBox Err.Description
Resume Exit_SeparateEmails
End If
End Sub