emailing a report as a snapshot

  • Thread starter Thread starter kaosyeti
  • Start date Start date
K

kaosyeti

i put this code in my close event of a report:

Private Sub Report_Close()

Dim msg, style, response As String

msg = "Do you want to email this report to John Doe?"
style = vbYesNo

On Error Resume Next

response = MsgBox(msg, style)
If response = vbYes Then
DoCmd.SendObject acSendReport, , acFormatSNP,
"(e-mail address removed)", , , "(subject)"
DoCmd.Restore
DoCmd.Close acForm, "formfinancelogreport"
Forms!formlauncher.Visible = True
Else
DoCmd.Restore
DoCmd.Close acForm, "formfinancelogreport"
Forms!formlauncher.Visible = True
End If

End Sub

it won't send the report for some reason. formfinancelogreport and
formlauncher are two forms that go visible=false when the report is opened.
it closes the report, closes the one form and sets visible to true on the
other (as it should). but no emails thus far. what am i missing?
 
You are missing the report name

Try the following
DoCmd.SendObject acReport, "(report name)", "SnapshotFormat(*.snp)", "(email
address)", "", "", "(subject)", "", False, ""
 
ya, that was actually an error in my post, not my code. when i wiped out the
real email address i must have wiped out that part too. i have this:

DoCmd.SendObject acSendReport, "rptmonthendreport", acFormatSNP, "(email
address)", , , "(subject)"

as that line of code. sorry bout that. anything else stick out as missing
or wrong?


Allan said:
You are missing the report name

Try the following
DoCmd.SendObject acReport, "(report name)", "SnapshotFormat(*.snp)", "(email
address)", "", "", "(subject)", "", False, ""
i put this code in my close event of a report:
[quoted text clipped - 26 lines]
it closes the report, closes the one form and sets visible to true on the
other (as it should). but no emails thus far. what am i missing?
 
Besides missing the report name try using the line of code as below.


DoCmd.SendObject acReport, "rptmonthendreport","SnapshotFormat(*.snp)",
"(email address)", "", "", "(subject)", "", False, ""

If in doubt create a macro to send your email, save the macro then use
tools-> options-> macro-> convert macro to VB. This will produce the macro
in the correct code.

--
Allan Murphy
Email: (e-mail address removed)
[email protected] via AccessMonster.com said:
ya, that was actually an error in my post, not my code. when i wiped out the
real email address i must have wiped out that part too. i have this:

DoCmd.SendObject acSendReport, "rptmonthendreport", acFormatSNP, "(email
address)", , , "(subject)"

as that line of code. sorry bout that. anything else stick out as missing
or wrong?


Allan said:
You are missing the report name

Try the following
DoCmd.SendObject acReport, "(report name)", "SnapshotFormat(*.snp)", "(email
address)", "", "", "(subject)", "", False, ""
i put this code in my close event of a report:
[quoted text clipped - 26 lines]
it closes the report, closes the one form and sets visible to true on the
other (as it should). but no emails thus far. what am i missing?
 
aarrghh. i did exactly what you said (both suggestions) and it didn't work.
it just closes the report and a tiny window pops up for about a quarter of a
second that says SOMETHING but it closes too quickly for me to see it. (even
if i remove the code about closing and visible=true on the other forms). i'm
just stuck.

Allan said:
Besides missing the report name try using the line of code as below.

DoCmd.SendObject acReport, "rptmonthendreport","SnapshotFormat(*.snp)",
"(email address)", "", "", "(subject)", "", False, ""

If in doubt create a macro to send your email, save the macro then use
tools-> options-> macro-> convert macro to VB. This will produce the macro
in the correct code.
ya, that was actually an error in my post, not my code. when i wiped out the
real email address i must have wiped out that part too. i have this:
[quoted text clipped - 16 lines]
 
by the way, if i set it up as:

docmd.runmacro "emailrptmonthendreport"

i get a window telling me that the macro failed. is it possible that access
is closing the report "before" sending the report with the macro/vba? if so,
is there a way to delay this so it works on the report's close event. i
absolutely need to be able to prompt the user to email this report or not so
i can't take away the msgbox part of all of this. i don't know my a$$ from
my elbow with vba so you'll forgive me if this question is obvious or not
entirely lucid. thanks.


aarrghh. i did exactly what you said (both suggestions) and it didn't work.
it just closes the report and a tiny window pops up for about a quarter of a
second that says SOMETHING but it closes too quickly for me to see it. (even
if i remove the code about closing and visible=true on the other forms). i'm
just stuck.
Besides missing the report name try using the line of code as below.
[quoted text clipped - 10 lines]
 
Back
Top