Connecting Tech Pros Worldwide Forums | Help | Site Map

SendObjects won't execute twice

Newbie
 
Join Date: Feb 2007
Posts: 2
#1: Feb 27 '07
I am a rank amateur and have taught myself enough to only just get away with some coding. I have now reached the limit of my capacity.
I am using MSAccess 2000 SR1 and am trying to use sendObjects to send a preformatted report in HTML format as an attachment to an email message.
The first time I perform this function (by way of button on a form) it works perfectly.
When I next try to do it (for a different record or the same record) it simply fails to execute. No error message or anything.
I am currently working around this by closing down Access and restarting it (works fine for one more message).

My code appears below:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command38_Click()
  2. On Error GoTo Err_Command38_Click
  3.  
  4.     Dim recipient, copies As String
  5.     Forms![Issue Status]![Customer].SetFocus
  6.     recipient = Me![Customer].Text
  7.     Forms![Issue Status]![InterestedParties].SetFocus
  8.     copies = Me![InterestedParties].Text
  9.     Dim subjecttext As String
  10.     Dim IssueRef As String
  11.     Dim DetailText As String
  12.     Forms![Issue Status]![Description].SetFocus
  13.     subjecttext = Me![Description].Text
  14.     Forms![Issue Status]![Issue Reference].SetFocus
  15.     IssueRef = Me![Issue Reference].Text
  16.     Forms![Issue Status]![Details].SetFocus
  17.     DetailText = Me![Details].Text
  18.  
  19.     DoCmd.SendObject acSendForm, "Issue Update All", acFormatHTML, _
  20.      recipient, copies, , _
  21.     "Issue Status Update: ( " & IssueRef & " ) " & subjecttext, "Detail: " & subjecttext & vbCrLf & DetailText & vbCrLf & vbCrLf & "Please find attached an update of this Issue", True
  22.     Forms![Issue Status]![Command38].SetFocus
  23. Exit_Command38_Click:
  24.     Exit Sub
  25.  
  26. Err_Command38_Click:
  27.     MsgBox Err.Description
  28.     Resume Exit_Command38_Click
  29.  
  30. End Sub
  31.  

msquared's Avatar
Administrator
 
Join Date: Aug 2006
Location: Dublin, Ireland
Posts: 10,886
#2: Feb 27 '07

re: SendObjects won't execute twice


All this will do is to send to the customer currently in focus. You will have to change the focus of the record to change the recipient. I've removed all the set focus commands as they are unnecessary.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command38_Click()
  2. On Error GoTo Err_Command38_Click
  3. Dim recipient, copies As String
  4. Dim subjecttext As String
  5. Dim IssueRef As String
  6.     Dim DetailText As String
  7.  
  8. recipient = Me![Customer]
  9. copies = Me![InterestedParties]
  10.  
  11. subjecttext = Me![Description]
  12. IssueRef = Me![Issue Reference]
  13. DetailText = Me![Details]
  14.  
  15.     DoCmd.SendObject acSendForm, "Issue Update All", acFormatHTML, _
  16.      recipient, copies, , _
  17.     "Issue Status Update: ( " & IssueRef & " ) " & subjecttext, "Detail: " & subjecttext & vbCrLf & DetailText & vbCrLf & vbCrLf & "Please find attached an update of this Issue", True
  18.  
  19. Exit_Command38_Click:
  20.     Exit Sub
  21.  
  22. Err_Command38_Click:
  23.     MsgBox Err.Description
  24.     Resume Exit_Command38_Click
  25.  
  26. End Sub
  27.  
Newbie
 
Join Date: Feb 2007
Posts: 2
#3: Mar 2 '07

re: SendObjects won't execute twice


Thanks for the cleanup, but the net result remains that the button will only work once.

Can you provide any advice as to how I reset whatever I need to reset in order to have it send a second message (either from the the same record or from another record) without having to close down Access and restart?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#4: Mar 2 '07

re: SendObjects won't execute twice


Check this out (SendObject - only works once!).
Reply