Function BatchPrint()
Email.SetFocus
'Stop error if email isnt sent
On Error GoTo Error
'Check for over 21 days
If Date > StartDate + 20 Then
'Email
If Email.Text <> "" Then
DoCmd.SendObject acReport, "rptLetter3", acFormatTXT, Email, , , "Overdue Fee Payment", "Please open the attached file", True
CheckLetter3.Value = True
Else
'Post
CheckLetter3.Value = True
DoCmd.OpenReport "rptLetter3", acViewNormal
End If
'Check for over 14 days
ElseIf Date > StartDate + 13 Then
'Email
If Email.Text <> "" Then
DoCmd.SendObject acReport, "rptLetter2", acFormatTXT, Email, , , "Overdue Fee Payment", "Please open the attached file", True
CheckLetter2.Value = True
Else
'Post
CheckLetter2.Value = True
DoCmd.OpenReport "rptLetter2", acViewNormal
End If
'Check for over 7 days
ElseIf Date > StartDate + 6 Then
'Email
If Email.Text <> "" Then
DoCmd.SendObject acReport, "rptLetter1", acFormatTXT, Email, , , "Overdue Fee Payment", "Please open the attached file", True
CheckLetter1.Value = True
Else
'Post
CheckLetter1.Value = True
DoCmd.OpenReport "rptLetter1", acViewNormal
End If
End If
'Catch error
Error:
'Resume Next
End Function
Private Sub Command13_Click()
'get a record count
Set rdset = CurrentDb.OpenRecordset("qryOutstanding")
rdset.MoveLast
rdset.MoveFirst
reccount = rdset.RecordCount
Set rdset = Nothing
If reccount = 1 Then
BatchPrint
Exit Sub
Else
a = 1
Do Until a = reccount
BatchPrint
a = a + 1
Loop
BatchPrint 'to get the last one
End If
End Sub