SendObject code

M

Mary

I'm using the following code to send an email on the after update event of a
form. It's working, but I'd like to include a second field in the Message
Text and insert a paragraph or new line if possible.

Private Sub Status_AfterUpdate()
Dim LResponse As Integer

LResponse = MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , , "Completed
Status Report", Forms!Maintain_Status!Field1 & "; " &
Forms!Maintain_Status!Field2, No
Else
Exit Sub
End If
End Sub

It works fine, but doesn't display the second field, just the first field
followed by the semi-colon separator.

Can you tell me what I'm doing wrong?
Thanks!
Mary
 
D

Dirk Goldgar

Mary said:
I'm using the following code to send an email on the after update event of
a
form. It's working, but I'd like to include a second field in the Message
Text and insert a paragraph or new line if possible.

Private Sub Status_AfterUpdate()
Dim LResponse As Integer

LResponse = MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , , "Completed
Status Report", Forms!Maintain_Status!Field1 & "; " &
Forms!Maintain_Status!Field2, No
Else
Exit Sub
End If
End Sub

It works fine, but doesn't display the second field, just the first field
followed by the semi-colon separator.

Can you tell me what I'm doing wrong?


Nothing obvious. The DoCmd.SendObject statement is correctly formed, except
that I would expect you to need to specify "False" instead of "No":

DoCmd.SendObject acSendNoObject, , , _
"(e-mail address removed)", , , _
"Completed Status Report", _
Forms!Maintain_Status!Field1 & "; " &
Forms!Maintain_Status!Field2, _
False

Are you sure there's something in Forms!Maintain_Status!Field2 when you run
the code?

If you want to put a new line between the two fields, try this:

DoCmd.SendObject acSendNoObject, , , _
"(e-mail address removed)", , , _
"Completed Status Report", _
Forms!Maintain_Status!Field1 & vbCrLf &
Forms!Maintain_Status!Field2, _
False

Add another vbCrLf if you want a blank line between them.
 
M

Mary

You were right, there wasn't anything in the field for the record I was
testing.

The new line code vbCrLf works great, thank you!

One more question.....

There are 3 statuses, and I really only want to send the SendObject to send
if the status is Completed. Where would I put that criteria?

Thanks!
Mary
 
D

Dirk Goldgar

Mary said:
You were right, there wasn't anything in the field for the record I was
testing.

The new line code vbCrLf works great, thank you!

One more question.....

There are 3 statuses, and I really only want to send the SendObject to
send
if the status is Completed. Where would I put that criteria?

Do you mean that there is one field that might have any of three different
statuses, or that there are three different status and you need to check to
see if any of them is "Completed"? And what are the field names involved?
 
M

Mary

Dirk Goldgar said:
Do you mean that there is one field that might have any of three different
statuses, or that there are three different status and you need to check to
see if any of them is "Completed"? And what are the field names involved?


There is one field that could have any of three different statuses.
 
D

Dirk Goldgar

Mary said:
There is one field that could have any of three different statuses.


Then I think you'd want something like this:

'----- start of code -----
Private Sub Status_AfterUpdate()

Dim LResponse As Integer

If Me.Status = "Completed" Then

LResponse = _
MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
DoCmd.SendObject acSendNoObject, , , _
"(e-mail address removed)", , , _
"Completed Status Report", _
Forms!Maintain_Status!Field1 & vbCrLf & _
Forms!Maintain_Status!Field2, _
False
End If

End If

End Sub
'----- start of code -----
 
M

Mary

Perfect - Thanks so much for your help!!

Dirk Goldgar said:
Then I think you'd want something like this:

'----- start of code -----
Private Sub Status_AfterUpdate()

Dim LResponse As Integer

If Me.Status = "Completed" Then

LResponse = _
MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
DoCmd.SendObject acSendNoObject, , , _
"(e-mail address removed)", , , _
"Completed Status Report", _
Forms!Maintain_Status!Field1 & vbCrLf & _
Forms!Maintain_Status!Field2, _
False
End If

End If

End Sub
'----- start of code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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

Similar Threads


Top