S
sue gray
I posted earlier today and can't find my original message. I have fixed my
earlier problem, but now I have another issue (of course).
The problem I am having is that I don't know how to filter to get the
results I want. My code will select one employee to email the report to, but
the attached report will have all employees included. I have tried
everything I can think of. Help is greatly appreciated.
Option Compare Database
Private Sub Email_RPT_to_All_Emp_Click()
On Error GoTo Some_Err
Dim strBody As String, lngCount As Long, lngRSCount As Long
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("All EmpTimeToDate_Crosstab")
lngRSCount = rst.RecordCount
If lngRSCount = 0 Then
MsgBox "No Reports to email.", vbInformation
Else
Do Until rst.EOF
lngRSCount = lngRSCount + 1
strTo = rst!EmailAddress
DoCmd.SendObject acSendReport, "All Emp Time", acFormatSNP, strTo, ,
, "Monthly Time", "Attached is your monthly time"
rst.MoveNext
Loop
End If
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
Close
MsgBox "Done sending Employee Time email. ", vbInformation, "Done"
Exit Sub
Some_Err:
MsgBox "Error (" & CStr(Err.Number) & ") " & Err.Description, _
vbExclamation, "Error!"
End Sub
earlier problem, but now I have another issue (of course).
The problem I am having is that I don't know how to filter to get the
results I want. My code will select one employee to email the report to, but
the attached report will have all employees included. I have tried
everything I can think of. Help is greatly appreciated.
Option Compare Database
Private Sub Email_RPT_to_All_Emp_Click()
On Error GoTo Some_Err
Dim strBody As String, lngCount As Long, lngRSCount As Long
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("All EmpTimeToDate_Crosstab")
lngRSCount = rst.RecordCount
If lngRSCount = 0 Then
MsgBox "No Reports to email.", vbInformation
Else
Do Until rst.EOF
lngRSCount = lngRSCount + 1
strTo = rst!EmailAddress
DoCmd.SendObject acSendReport, "All Emp Time", acFormatSNP, strTo, ,
, "Monthly Time", "Attached is your monthly time"
rst.MoveNext
Loop
End If
rst.Close
db.Close
Set rst = Nothing
Set db = Nothing
Close
MsgBox "Done sending Employee Time email. ", vbInformation, "Done"
Exit Sub
Some_Err:
MsgBox "Error (" & CStr(Err.Number) & ") " & Err.Description, _
vbExclamation, "Error!"
End Sub