J
Jason Gyetko
I have a report which I need to print and email from code.
I'm running the following line of code which prints the report (includes a
where clause to filter data)
DoCmd.OpenReport "rptPacklist", acPrintAll, ,
"[ANYUSER_MANHDR]![MNH_MH_CNTR] ='" & Control_Nbr & "'"
I'm not sure how I can email it when the report is run. I know I can use
the following command immediately after the above command, but that means
I'm actually running the report twice then.
DoCmd.SendObject acReport, "rptPacklist", acFormatSNP, "(e-mail address removed)",
, , "Packing List - Control Number " & Control_Nbr, "Packing List included
as attachment", False
Ideally, I want to run that first command then have a line in the actual
report telling it to email itself to someone. Does anyone know how I can do
that?
I've tried adding that second command (SendObject) to the report in several
spots and received the following error messages:
Report_Open()
----------------
The expression On Open you entered as the event property setting produced
the following error: Procedure declaration does not match description of
event or procedure having the same name.
Report_Close()
----------------
Run-time error '2585': This action can't be carried out while processing a
form or report event.
Report_Activate()
----------------
Works if I actually open the report, but when using that first acPrintAll
command (listed above), it does nothing (I'm guessing cause the report is
never actually opened and activated).
Any suggestions would be greatly appreciated. Thanks in advance.
I'm running the following line of code which prints the report (includes a
where clause to filter data)
DoCmd.OpenReport "rptPacklist", acPrintAll, ,
"[ANYUSER_MANHDR]![MNH_MH_CNTR] ='" & Control_Nbr & "'"
I'm not sure how I can email it when the report is run. I know I can use
the following command immediately after the above command, but that means
I'm actually running the report twice then.
DoCmd.SendObject acReport, "rptPacklist", acFormatSNP, "(e-mail address removed)",
, , "Packing List - Control Number " & Control_Nbr, "Packing List included
as attachment", False
Ideally, I want to run that first command then have a line in the actual
report telling it to email itself to someone. Does anyone know how I can do
that?
I've tried adding that second command (SendObject) to the report in several
spots and received the following error messages:
Report_Open()
----------------
The expression On Open you entered as the event property setting produced
the following error: Procedure declaration does not match description of
event or procedure having the same name.
Report_Close()
----------------
Run-time error '2585': This action can't be carried out while processing a
form or report event.
Report_Activate()
----------------
Works if I actually open the report, but when using that first acPrintAll
command (listed above), it does nothing (I'm guessing cause the report is
never actually opened and activated).
Any suggestions would be greatly appreciated. Thanks in advance.