I have a form that has multiple fields. It has 4 fields. One of them happens to be a comment field. Sometimes there is a comment and sometimes there is not. When there is not a comment I get an error. When I debug it stops here where I have it underlined: .body = Me.Comments
How do I make it save not matter whats in the box?
How do I make it save not matter whats in the box?
Code:
Private Sub cmdAddToCalendar_Click()
On Error GoTo Add_Err
'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
With objAppt
.Start = DateAdd("d", 90, LastEmploymentDate.Value) '& " " & Me!ApptTime
.Duration = 1440
.Subject = "Notify " & Me.NotifyName & " about " & Me.EmployeeName
.ReminderMinutesBeforeStart = 15
.ReminderSet = True
[U].Body = Me.Comments[/U]
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
'Release the Outlook object variable.
Set objOutlook = Nothing
MsgBox "Appointment Added!"
Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Comment