Posting appt in Access to Public Folder

G

Guest

My code for posting an appointment to my personal folder works fine, but when
I try to post it to a public folder, it goes to my personal folder. Does
anyone know what I left out?

Private Sub OutLkBtn_Click()
On Error GoTo Add_Err
'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 is already added to Microsoft Outlook"
Exit Sub
'Add a new appointment
Else
Dim objoutlook As Outlook.Application
Dim nms As Outlook.Namespace
Dim fld As Outlook.MAPIFolder
Dim objappt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objoutlook = CreateObject("Outlook.Application")
Set nms = objoutlook.GetNamespace("MAPI")
Set fld = nms.Folders("Public Folders").Folders("all public
folders").Folders("Calendar")
Set objappt = objoutlook.CreateItem(olAppointmentItem)
With objappt
.Start = Me!ApptStartDate '& " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objappt = Nothing
'Release the object variables.
Set objoutlook = Nothing
Set objRecurPattern = Nothing
'Set the AddedToOutlook flag, save the record, display
'a message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
'Visible = False
End If

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