Select Calender for Adding New Appointments

R

ritland

I have created a command button on my Access form that enters the
birthday of the individual into my default Outlook calendar. However,
I want to add this information to a specific public calendar on my
network instead. How can I do this?

Secondly, is it possible to link entries in my database with specific
Outlook appointments so that a change in the database changes the
appointment? For instance, if an individual in the database has an
Outlook appointment for his birthday then that individual's
information is modified or removed, can a corresponding action be
taken in the Outlook calendar automatically? Thanks!

My code is as follows:

Private Sub cmdAddBirthdayPrimary_Click()
On Error GoTo Add_Err
'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
If IsNull(Me!DOB) Then
MsgBox "No birthday entered."
Exit Sub
Else

DOBMonth = DatePart("m", [DOB])
DOBDay = DatePart("d", [DOB])


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 = DOBMonth & "/" & DOBDay
.Duration = "1440"
.Subject = Me!FirstName & " " & Me!LastName & " Birthday "
& "- " & Me!DOB
.ReminderSet = False

Set objRecurPattern = .GetRecurrencePattern

With objRecurPattern
.RecurrenceType = olRecursYearly
.Interval = 1
End With

.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
' MsgBox "This birthday has been entered into the Outlook
calendar on " & DOBMonth & "/" & DOBDay & "."
End If
'Release the Outlook object variable.
Set objOutlook = Nothing


Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top