I have an Access DB that is used by multiple users. I have set it up to link the appointments to my default Outlook calendar, but would like to allow any user in the DB to be able to send it to a nondefault created Calendar that we all share.
Here is my current code. I have tried several other threads' ideas without any success.
The shared Calendar is named BloodDrives.
Private Sub AddAppt_Click()
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
If Me!AddedtoOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
Exit Sub
' Add a new appointment.
Else
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Me!DriveDate & " " & Me!StartTime
.Duration = Me!DriveDurationMinutes
.Subject = Me!ClubName
If Not IsNull(Me!DriveType) Then .Body = Me!DriveType
If Not IsNull(Me!DriveLocation) Then .Location = _
Me!DriveLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!AddedtoOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Here is my current code. I have tried several other threads' ideas without any success.
The shared Calendar is named BloodDrives.
Private Sub AddAppt_Click()
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Exit the procedure if appointment has been added to Outlook.
If Me!AddedtoOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
Exit Sub
' Add a new appointment.
Else
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Me!DriveDate & " " & Me!StartTime
.Duration = Me!DriveDurationMinutes
.Subject = Me!ClubName
If Not IsNull(Me!DriveType) Then .Body = Me!DriveType
If Not IsNull(Me!DriveLocation) Then .Location = _
Me!DriveLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
.Save
End With
End If
' Release the Outlook object variable.
Set outobj = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!AddedtoOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub