Option Not to send email

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

Can I adjust this so as I have the otion not to send
email.............Thanks Bob

msgTitle = "E-Mail"
msgBtns = vbYes + vbQuestion + vbDefaultButton2 + vbApplicationModal
msgPmt = " Create E-mail "
msgResp = MsgBox(msgPmt, msgBtns, msgTitle)
If msgResp = vbCancel Then
Exit Sub
Else
blEditMail = IIf(msgResp = vbYes, False, True)
End If

DoCmd.SendObject acSendReport, Me.Name, acFormatRTF, strMail, , , "Your
Invoice " & IIf(Len(strHorse) > 0, " / " & strHorse, ""), _
strBodyMsg, blEditMail
 
Hi Bob,

How about moving the DoCmd.SendObject above the End If? Something like this:

msgTitle = "E-Mail"
msgBtns = vbYes + vbQuestion + vbDefaultButton2 + vbApplicationModal
msgPmt = " Create E-mail "
msgResp = MsgBox(msgPmt, msgBtns, msgTitle)
If msgResp = vbCancel Then
Exit Sub
Else
blEditMail = IIf(msgResp = vbYes, False, True)

DoCmd.SendObject acSendReport, Me.NAME, acFormatRTF, strMail, , , _
"Your Invoice " & IIf(Len(strHorse) > 0, " / " & strHorse, ""), _
strBodyMsg, blEditMail

End If


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
PS.
Bob Quintal is correct that vbCancel is not appropriate. When I just ran
your code, I only had an OK choice, not a Yes or No choice. However, when I
ran Bob Q's revision, I now have the indicated Yes and No buttons. I had not
caught that in my initial reply.

I question the Me.NAME parameter in the DoCmd.SendObject line of code. If
your code is running in the class module associated with a form, then the
name of the form will be inserted here for Me.Name. Unless you happen to have
a report named identically to your form, this code will not work.


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
 
Thanks Bob The [No] worked perfect ,BUT [Yes] brings up a pesky Microsoft
Office Outlook Warning: A Program is trying to send..................
Where as before It opened up as an email then I Clicked send on Outlook
Thanks for the help...Bob
 
Thanks Tom, Name is an expression in my query I suppose it was a stupid name
to call it <smile>
If idHorse <> 0 Then
strHorse = Nz(DLookup("[Name]", "qryHorseNameAll", "[HorseID]=" &
idHorse), "")
 
Hi Bob,

My advice is to always avoid using any reserved words or special characters
for things that you assign a name to in Access. This includes field names,
names of tables, queries, forms, reports, macros, modules, and names of
controls on forms and reports. Access MVP Allen Browne maintains an extensive
listing of reserved words, and has a free utility available that you can use
to scan your databases for the use of reserved words, among other problems:

Problem names and reserved words in Access
http://allenbrowne.com/AppIssueBadWord.html

Here is a Microsoft KB article on the use of special characters:

Special characters that you must avoid when you work with Access databases
http://support.microsoft.com/?id=826763


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
Back
Top