Hello All,
I have been trying to get a command button to send an email based on modified code from thread 702-396121 and am stuck.
I have a button on a subform which initiates data collection from both the subform and the parent form. It then starts an Outlook e-mail in which the user can fill in the e-mail addresses of the recipient and cc recipient.
My problem comes in a If .. Then .. Else portion which chooses the Subject line based on a radio button selection of an option group. I keep receiving a compilation error "Else without If" yet cannot see a problem. Can anyone out there help?
Thanks a bunch
TechieJr.
PS. Let me know what part of my script I need to explain to help you troubleshoot it.
I have been trying to get a command button to send an email based on modified code from thread 702-396121 and am stuck.
I have a button on a subform which initiates data collection from both the subform and the parent form. It then starts an Outlook e-mail in which the user can fill in the e-mail addresses of the recipient and cc recipient.
My problem comes in a If .. Then .. Else portion which chooses the Subject line based on a radio button selection of an option group. I keep receiving a compilation error "Else without If" yet cannot see a problem. Can anyone out there help?
Thanks a bunch
TechieJr.
PS. Let me know what part of my script I need to explain to help you troubleshoot it.
Code:
Private Sub Command47_Click()
Dim CallerName As String, Comp As String, BusPh As String, Called As String, _
contype As String, FolUp As String, Note As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
CallerName = Forms![f_daylogentry]!Combo10
Comp = Forms![f_daylogentry]!Company
BusPh = Forms![f_daylogentry]!BusPhone
Called = Me!CalledFor
Note = Me!Comments
If Me!ContactType = "3" Then contype = "Visitor came to see "
Else
contype = "Phone Call for "
End If
If Me!Action = "4" Then FolUp = "Returned your call."
ElseIf Me!Action = "3" Then FolUp = "Will call back."
Else
FolUp = "Please call."
End If
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.Subject = contype & " " & Called
.Body = CallerName & " of " & Comp & " (" & BusPh & ") " & Chr(13)
.Body = Body & FolUp & Chr(13)
.Body = Body & Note
.Display
End With
Set objEmail = Nothing
End Sub