In a report, can I loop through a table to pick the parameter. I can't seem to hit the right combination to have the report only show me the "ReportsTo" from the tbl ReportsTo2 for that individual, it continually shows me all results; or do I have to look at this another way.
Private Sub Command58_Click()
On Error GoTo Exit_Command58_Click
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("ReportsTo2") 'table
Dim stDocName As String
stDocName = "5MgrApproval-1"
DoCmd.SetWarnings False
DoCmd.OpenQuery "5MgrApproval3-Test", acNormal, acEdit
rs.MoveFirst
Do While Not rs.EOF
DoCmd.OpenReport stDocName, , , , "reportsto=" & rs!reportsto
DoCmd.SendObject acReport, stDocName, "PdfFormat(*.pdf)", rs!emailAddress, "", "", "Manager Approval", "", True, """"""
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
MsgBox "Reports Completed", vbOKOnly, "Month End PTO"
Exit_Command58_Click:
If MsgBox("Do you want to cancel the run?", vbQuestion Or vbYesNo) = vbYes Then
Exit Sub
Else
Resume Next
End If
End Sub
Appreciate any direction you may give me.
Thanks for the help.
Greg
Private Sub Command58_Click()
On Error GoTo Exit_Command58_Click
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("ReportsTo2") 'table
Dim stDocName As String
stDocName = "5MgrApproval-1"
DoCmd.SetWarnings False
DoCmd.OpenQuery "5MgrApproval3-Test", acNormal, acEdit
rs.MoveFirst
Do While Not rs.EOF
DoCmd.OpenReport stDocName, , , , "reportsto=" & rs!reportsto
DoCmd.SendObject acReport, stDocName, "PdfFormat(*.pdf)", rs!emailAddress, "", "", "Manager Approval", "", True, """"""
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
MsgBox "Reports Completed", vbOKOnly, "Month End PTO"
Exit_Command58_Click:
If MsgBox("Do you want to cancel the run?", vbQuestion Or vbYesNo) = vbYes Then
Exit Sub
Else
Resume Next
End If
End Sub
Appreciate any direction you may give me.
Thanks for the help.
Greg