emailing a report as a snapshot

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?
 
A

Allan Murphy

You are missing the report name

Try the following
DoCmd.SendObject acReport, "(report name)", "SnapshotFormat(*.snp)", "(email
address)", "", "", "(subject)", "", False, ""
 
K

kaosyeti

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?
 
A

Allan Murphy

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?
 
K

kaosyeti

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]
 
K

kaosyeti

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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top