I have a form that I compose an email to a contact then a command button sends the info to Outlook. Also on that form is a command button to save the record to the contact notes table.
The problem I have found is that if I send to outlook prior to saving, then try to save the record, it does not update my contact notes table.
What I need to do is combine the two routines into one so that the record is saved, then sent to outlook.
Code for each command follows:
__________________________________
Private Sub Command7_Click()
Dim email, ref, destination, notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**gathers information from your form. this sets the string variable to your fields
email = Me!email_address
ref = Me!subject
notes = Me!message
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.Display
.To = email
.subject = ref
.HTMLBody = "<p>" & notes & "<p>" & .HTMLBody
End With
Exit Sub
End Sub
____________________________________
Private Sub Command8_Click()
On Error GoTo Command8_Click_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "ContactLogEntryFMAppendNewEmailQRY", acViewNormal, acEdit
DoCmd.SetWarnings True
DoCmd.Close
Command8_Click_Exit:
Exit Sub
Command8_Click_Err:
MsgBox Error$
Resume Command8_Click_Exit
End Sub
__________________________________
Both routines work fine, but I sometimes forget to save the record first.
As always, help is appeciated.
The problem I have found is that if I send to outlook prior to saving, then try to save the record, it does not update my contact notes table.
What I need to do is combine the two routines into one so that the record is saved, then sent to outlook.
Code for each command follows:
__________________________________
Private Sub Command7_Click()
Dim email, ref, destination, notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**gathers information from your form. this sets the string variable to your fields
email = Me!email_address
ref = Me!subject
notes = Me!message
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.Display
.To = email
.subject = ref
.HTMLBody = "<p>" & notes & "<p>" & .HTMLBody
End With
Exit Sub
End Sub
____________________________________
Private Sub Command8_Click()
On Error GoTo Command8_Click_Err
DoCmd.SetWarnings False
DoCmd.OpenQuery "ContactLogEntryFMAppendNewEmailQRY", acViewNormal, acEdit
DoCmd.SetWarnings True
DoCmd.Close
Command8_Click_Exit:
Exit Sub
Command8_Click_Err:
MsgBox Error$
Resume Command8_Click_Exit
End Sub
__________________________________
Both routines work fine, but I sometimes forget to save the record first.
As always, help is appeciated.