Email a Report, Please

K

KAnoe

I have been working on this and it may be over my head. I need to set up a
cmd-btn that the user can use to send a report. Im working on the DoCmd.send
but I cant get it. Here is what I have now. But I get a Compile error. What
am i messing!?

Private Sub cmd_btn_email_daily_rpt_Click()
DoCmd.SendObject , Daily_Rpt, , "(e-mail address removed)", , , "Daily Report", , , True
End Sub

Any help would be great

Thanks
Keith
 
D

Dan Artuso

Hi,
If you look up the syntax in Help, you have to specify the object type and the
report name is a string so...
DoCmd.SendObject acSendReport, "Daily_Rpt", , "(e-mail address removed)", , , "Daily Report", , True
 
K

KAnoe

OK,

I now have the code like this

DoCmd.SendObject acSendReport, Daily_Rpt.rtf, , "(e-mail address removed)", , , "Daily
Report", , , True

I see that I needed to add the acSendReport and why. I also see in the help
that I need to tell it the format that it needs to me in so I put it in rich
text. with the above code I get the following:

Compile Error
Variable not defined.

I'm think that I have not told it the format in the right format.

Thanks
 
D

Dan Artuso

Hi,
From Help:
outputformat One of the following intrinsic constants:
acFormatHTML
acFormatRTF
acFormatTXT
acFormatXLS
If you leave this argument blank, Microsoft Access prompts you for the output format.

You cannot simply make things up and supply them as arguments :)
 
R

Rob Oldfield

....and the second argument needs to be the (string) name of the report. So
1) it needs to be in speech marks and 2) you don't have a report called
Daily_Rpt.rtf (not allowed... at least not in A2K)
 
D

Dan Artuso

Good catch.
KAnoe, please read the replies carefully and pay attention the what the help
files say! You didn't even implement the changes I suggested in my earlier post.
 
K

KAnoe

OK Dan. I thought I did. On my code I his not have the "acSendReport" in the
code. I thought this was the change. I will read both the email and the help
again. Sorry if I missed it. I find that by the time I get it I look back and
see that I should have seen it in the first palce. I think that is what is
going on here.

Thanks Keith
 
K

KAnoe

GOT IT!! Thanks DAN and Rob!!!!!

KAnoe said:
OK Dan. I thought I did. On my code I his not have the "acSendReport" in the
code. I thought this was the change. I will read both the email and the help
again. Sorry if I missed it. I find that by the time I get it I look back and
see that I should have seen it in the first palce. I think that is what is
going on here.

Thanks Keith
 

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