emailing reports

B

blake7

Hi I am using the following code to send my reports via lotus notes, it works
fine but keeps asking me what format I want to send it in eg 'rich text
format' i choose rtf as my choice but would like to know where in the code I
would input something to always choose rtf. ??

DoCmd.SendObject acReport,"reportName",,"email address",,,"Subject",,True

Thank You in advance
 
R

Rob Parker

The third parameter in the .SendObject method specifies the format. Change
your code to:

DoCmd.SendObject acReport,"reportName", acFormatRTF,"email
address",,,"Subject",,True

and all should be well.

HTH,

Rob

PS. BTW, I didn't know that if you omitted this parameter you would receive
a prompt for it. My solution is untested, but I expect it to work ;-)
 
B

blake7

Thanks Rob, that works great, just another quick question, when the report
runs i have a criteria in the query that forms the basis of the report, I am
using the initials of my work team so obviousley it asks for these initials
before going into lotus notes, is there any way you can add into the code the
initials of the relevant person so that it does not prompt for them. I have
eight different buttons on my form each dedicated to a member of my team and
the code is behind each button. Hope you can help.
Regards Tony
 
R

Rob Parker

Hi Tony,

The standard way of doing this when you open a report via code is to include
the parameter value in the WHERE parameter of the DoCmd.OpenReport command.
Unfortunately, when you are using SendObject, there is no WHERE parameter.
But there's another way (or even several ways - I'll describe the simplest):

Put an unbound textbox (let's call it txtInitials) on the form into which
the user inputs his/her initials before clicking the button. In the query
which is the report's record source, add the following in the criteria field
for the field on which you wish to filter:
=[Forms].[YourFormName].[txtInitials]

You could also wrap the DoCmd.SendObject line in an If statement to ensure
that the textbox is not empty:
If Len((txtInitials) & "") = 0 Then 'also check for zero-length string
MsgBox "Please enter your initials"
txtInitials.SetFocus
Else
DoCmd.SendObject ...
End If

Doing it this way should also mean that you only need a single command
button to send the reports, rather than a separate one for each person; the
latter is a rather clunky design, if you don't mind my saying so ;-)

Again, HTH,

Rob
 

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