Sending Emails From MS Access

  • Thread starter Thread starter fiona.innes
  • Start date Start date
F

fiona.innes

Hiya,

What I require to do is have a email button on my frmDetails so that
when a user clicks on it it composes an email which sends to the email
address (e-mail address removed) from MS Outlook and have the text "New
Freight has been added to the warehouse with booking ref:" and it
then inserts the booking ref from the field strBookingRef on the
frmDetails. When the email is sent I would like the email button to
be disabled.

Any ideas

Fiona
 
Put this code in the click event of your E-Mail button

DoCmd.SendObject acSendNoObject, , , "(e-mail address removed)", , , "Your
Subject Line", "New Freight has been added to the warehouse with booking ref:
" & strBookingRef, False

SomeOtherControlOnYourForm.SetFocus
EMailButton.Enabled = False
 
Thanks the 1st bit works, where do you put

SomeOtherControlOnYourForm.SetFocus
EMailButton.Enabled = False


confused?

Fiona
 
In the click event of your email button, straight after the DoCmd.SendObject
... line
The SomeOtherControlOnYourForm needs to be the name of a control on your
form because you cannot disable the button if it has the focus. It will have
the focus because you have just clicked it.
 
Yes but you have to move the focus off it before it can be disabled. That is
what those 2 lines of code do. Move the focus in your access form to another
control other your your e-mail button, then diable the e-mail button.
 
What Dennis is saying by setting the focus to another field is something if
you have a comments field on your form then use the code Dennis gave you to
look like this:

Me.Comments.SetFocus
EmailButton.Enabled = False

Or use your bookingref field

Me.Bookingref.SetFocus
EmailButton.Enabled=False



Provided the name of your Comments field is Comments
 
Back
Top