Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sendobject works once

Status
Not open for further replies.

PatSalmon

Technical User
Jul 5, 2001
27
CA
I have a sendobject command in a module at the end of a number of queries. Once the queries are run an e-mail is sent to a distribution list. This works well the first time. If I try to run the module a second time, the queries run but the email doesn't. The message text is not long, less than 200 characters. If I shut down the Access app and restart it's fine again, for one run.

Any ideas on this?

Thanks
Pat
 
i may be way off, but are you using global variables at all, i've seen this happen (accualy i did it)... that's why i try to never use globals if i can... i alwas use calling arg's... just a thought because if you use global variables, then they don't get reset to null when the current code complete's and looses focus...

also, i'm half asleep while typing this, so if i make no sence at all, just ignor me...

--James
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
I don't believe I am. It is a pretty simple code:

DoCmd.SendObject , "rptEMail", "RichTextFormat(*.rtf)", "test", "", "", "Weekly Shipment Report", "Please find the weekly shipments are posted at the bottom of the following page: False, ""

I'm not really clear on what you mean by global variables.

Thanks
Pat
 
ok, from that code it looks like there's no to:
is this email suposed to go any where?? or bring up the email window all filled in and let you choose who it's going to? JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
The to is a distribution list called "test" (right after the "RichTextFormat(*.rtf)". It does send the mail automatically without allowing edit, the first time it is run. After that I must shut and start Access again.

Thanks
Pat
 
it looks like this might work, i beond this, i don't think i can be of any more help... sorry.

--James


DoCmd.SendObject acSendReport, "rptEMail", "RichTextFormat(*.rtf)", "test", "", "", "Weekly Shipment Report", "Please find the weekly shipments are posted at the bottom of the following page: False, ""
JHauge@jmjpc.net
Life is change. To deny change is to deny life.
 
Thanks anyway. It isn't the end of the world, but I would like to understand why.

Thanks
Pat
 
I'd start by eliminating all parameter values not required and use the following...

Code:
DoCmd.SendObject ObjectType:=acSendReport, _
                    ObjectName:="rptEMail", _
                    OutputFormat:=acFormatRTF, _
                    To:="test", _
                    Subject:="Weekly Shipment Report", _
                    MessageText:="Please find the weekly shipments are posted at the bottom of the following page: [URL unfurl="true"]Http://intranet.com/manufacturing/ordermgt/om-reports.html",[/URL] _
                    Editmessage:=False

The OutputFormat has an intrinsic constant. I've replaced the string you've used. In addition, I've removed the ;; from the MessageText. They were outside the string "" and may have affected the results required.

This doesn't necessarily address why the process won't run more than once without closing the application and re-opening it. Is there other code above or below the DoCmd.SendObject function that may be hindering your processing?
 
I replace my command with yours, it worked but only the first time. The only other commands before this one, are DoCmd.OpenQuery's that run a series of queries. I can't see that they would affect the email portion,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top