Access 15.0 vs 16.0 object library- keeps going missing

  • Thread starter Thread starter SarahPF
  • Start date Start date
S

SarahPF

Guest
So I'll preface with this- I know just enough about Access to get in trouble. I am using Access 2013, but have some folks with access to the database that is causing problems that use 2016. Most days the "Microsoft Outlook 16.0 object library" becomes "missing" and throws out error codes. When I go to fix the reference, I can only select 15.0; I do not have 16.0 in my available reference list. Selecting 15.0 will work as a band-aid, but I'll get the error/missing reference again in just a day or two. I'm looking for a permanent fix.

I believe that the problem lies somewhere in the code attached below; this was copied off the internet and I modified it for my use (which it works! This is the On Click event for a button -it adds an event to the outlook calendar!). I'm not sure if there is a way to modify this that it will work for both versions of Access, assuming that is my problem to begin with.

Thanks for whatever advice you can offer!

Private Sub AddAppt_Click()
On Error GoTo AddAppt_Err
' Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord
' Add a new appointment.
Dim outobj As Outlook.Application
Dim outappt As Outlook.AppointmentItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olAppointmentItem)
With outappt
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!leaveLength
.Subject = Me!Apptdata
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = _
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!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.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
AddAppt_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub

Continue reading...
 
Back
Top