I have a continuous form for scheduling that I want to be able to add to the outlook calendar so I created a button with the following code:
(isappthere is a boolean function)
Dim myReply
myReply = MsgBox("Do you wish to add this appointment to your Outlook Calender", vbYesNo)
If myReply = vbYes Then
If Me.Dirty Then
Me.Dirty = False
End If
' Use late binding to avoid the "Reference" issue
Dim olapp As Object ' Outlook.Application
Dim olappt As Object ' olAppointmentItem
'early binding
'Dim olapp As Outlook.Application
'Dim olappt As Outlook.AppointmentItem
'Set olapp = CreateObject("Outlook.Application")
'Set olappt = olapp.createitem(olappointmentitem)
If isAppThere("Outlook.Application") = False Then
' Outlook is not open, create a new instance
Set olapp = CreateObject("Outlook.Application")
Else
' Outlook is already open--use this method
Set olapp = GetObject(, "Outlook.Application")
End If
Set olappt = olapp.createitem(1) ' (olappointmentitem)
With olappt
.start = Me.BeginDateTime
.End = Me.EndDateTime
.subject = "Worker Scheduled" & " " & Me.WorkerCombo.Column(1)
.body = Me.WorkerCombo.Column(1) & " " & Me.Notes
If IsNull(Me.WorkOrderID) Then
.location = DLookup("BuildingName", "WorkOrderQ", "WorkOrderID=" & Forms!ReviewWorkOrderF!WorkOrderID)
ElseIf Not IsNull(Me.WorkOrderID) Then
.location = (General)"
End If
.reminderminutesbeforestart = 60
.reminderset = True
.Save
End With
Set olappt = Nothing
Set olapp = Nothing
MsgBox "Appointment Added to Outlook!", vbInformation
ElseIf myReply = vbNo Then
Exit Sub
End If
The problem is the button only syncs the single record that is the focus. I want it to sync all the records displayed on the continuous form. Is this possible?
Thanks for the help!
(isappthere is a boolean function)
Dim myReply
myReply = MsgBox("Do you wish to add this appointment to your Outlook Calender", vbYesNo)
If myReply = vbYes Then
If Me.Dirty Then
Me.Dirty = False
End If
' Use late binding to avoid the "Reference" issue
Dim olapp As Object ' Outlook.Application
Dim olappt As Object ' olAppointmentItem
'early binding
'Dim olapp As Outlook.Application
'Dim olappt As Outlook.AppointmentItem
'Set olapp = CreateObject("Outlook.Application")
'Set olappt = olapp.createitem(olappointmentitem)
If isAppThere("Outlook.Application") = False Then
' Outlook is not open, create a new instance
Set olapp = CreateObject("Outlook.Application")
Else
' Outlook is already open--use this method
Set olapp = GetObject(, "Outlook.Application")
End If
Set olappt = olapp.createitem(1) ' (olappointmentitem)
With olappt
.start = Me.BeginDateTime
.End = Me.EndDateTime
.subject = "Worker Scheduled" & " " & Me.WorkerCombo.Column(1)
.body = Me.WorkerCombo.Column(1) & " " & Me.Notes
If IsNull(Me.WorkOrderID) Then
.location = DLookup("BuildingName", "WorkOrderQ", "WorkOrderID=" & Forms!ReviewWorkOrderF!WorkOrderID)
ElseIf Not IsNull(Me.WorkOrderID) Then
.location = (General)"
End If
.reminderminutesbeforestart = 60
.reminderset = True
.Save
End With
Set olappt = Nothing
Set olapp = Nothing
MsgBox "Appointment Added to Outlook!", vbInformation
ElseIf myReply = vbNo Then
Exit Sub
End If
The problem is the button only syncs the single record that is the focus. I want it to sync all the records displayed on the continuous form. Is this possible?
Thanks for the help!