By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,477 Members | 1,602 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,477 IT Pros & Developers. It's quick & easy.

SendObjects won't execute twice

P: 2
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.  
Feb 27 '07 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
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.  
Feb 27 '07 #2

P: 2
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?
Mar 2 '07 #3

NeoPa
Expert Mod 15k+
P: 31,186
Check this out (SendObject - only works once!).
Mar 2 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.