poohbear2012
Registered User.
- Local time
- Today, 22:38
- Joined
- Jan 8, 2012
- Messages
- 30
Hi
I am trying to write coding to enable the user to click on a button to send an email including fields from the active record.
I am currently experiencing issues with the lines highlighted in bold. It is coming up with the following error:
Compile Error
Expected: Line number or label or statement or end of statement.
Am not sure how to correct this as the references to the fields are correct and have tried different versions of line breaking without success.
Please advise what I am doing wrong...
Private Sub btnsendemail_Click()
If IsNull(Me.txtcount) Then
MsgBox "There are no appointments to email"
Else
On Error GoTo handdler
Dim objOL As Outlook.Application
Set objOL = New Outlook.Application
Dim ObjOLMsg As Outlook.MailItem
Set ObjOLMsg = Olk.CreateItem(olMailItem)
With ObjOLMsg
Dim ObjOLRecip As Outlook.Recipient
Set ObjOLRecip = .Recipients.Add(joebloggs@google.com)
ObjOLRecip.Type = olCC
.Subject = "Appointment Reminder"
.Body = "Thank you for your referral regarding" & Nz(Me.Forename, "") & "& Nz (Me.Surname,"")_"
& vbCrLF & "We have booked an outpatient appointment for them to be seen in" & Nz (Me.Consultant,"")& "clinic on" & Nz(Me.1st_Appointment,"") "at insert time." _
& vbCrLF & "Kind Regards" _
& vbCrLF & "The Appointment Team."_
& vbCrLF & "This message has been automatically generated by the Booking Database System"
End If
handdler:
If Err.Number = 2501 Then
MsgBox "You have cancelled the request", vbInformation
Else
Exit Sub
End If
End Sub
Regards
Trisha
I am trying to write coding to enable the user to click on a button to send an email including fields from the active record.
I am currently experiencing issues with the lines highlighted in bold. It is coming up with the following error:
Compile Error
Expected: Line number or label or statement or end of statement.
Am not sure how to correct this as the references to the fields are correct and have tried different versions of line breaking without success.
Please advise what I am doing wrong...
Private Sub btnsendemail_Click()
If IsNull(Me.txtcount) Then
MsgBox "There are no appointments to email"
Else
On Error GoTo handdler
Dim objOL As Outlook.Application
Set objOL = New Outlook.Application
Dim ObjOLMsg As Outlook.MailItem
Set ObjOLMsg = Olk.CreateItem(olMailItem)
With ObjOLMsg
Dim ObjOLRecip As Outlook.Recipient
Set ObjOLRecip = .Recipients.Add(joebloggs@google.com)
ObjOLRecip.Type = olCC
.Subject = "Appointment Reminder"
.Body = "Thank you for your referral regarding" & Nz(Me.Forename, "") & "& Nz (Me.Surname,"")_"
& vbCrLF & "We have booked an outpatient appointment for them to be seen in" & Nz (Me.Consultant,"")& "clinic on" & Nz(Me.1st_Appointment,"") "at insert time." _
& vbCrLF & "Kind Regards" _
& vbCrLF & "The Appointment Team."_
& vbCrLF & "This message has been automatically generated by the Booking Database System"
End If
handdler:
If Err.Number = 2501 Then
MsgBox "You have cancelled the request", vbInformation
Else
Exit Sub
End If
End Sub
Regards
Trisha
