I am currently using this code to send an appointment to Outlook. It sends the info to a form called "frmAppointment s" and then to Outlook. This code works great to send the record that is in focus. I would like to be able to have the ability to send multiple records as appointments. How do I do more than one at a time?
Code:
Form_frmAppointments!ApptDate = [Form_Maintenance Subform3].[Next Maintenance]
'Form_frmAppointments!ApptTime = Me![Sample Run Time]
Form_frmAppointments!Appt = Me.Text80
Form_frmAppointments!ApptReminder = True
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Form_frmAppointments!ApptDate & " " & Form_frmAppointments!ApptTime
.Duration = Form_frmAppointments!ApptLength
.Subject = Form_frmAppointments!Appt
.Categories = "Maintenance"
If Not IsNull(Form_frmAppointments!ApptNotes) Then .Body = Form_frmAppointments!ApptNotes
If Not IsNull(Form_frmAppointments!ApptLocation) Then .Location = _
Form_frmAppointments!ApptLocation
If Form_frmAppointments!ApptReminder Then
.ReminderMinutesBeforeStart = Form_frmAppointments!ReminderMinutes
.ReminderSet = True
End If
.Save
End With
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Form_frmAppointments!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
Comment