Unanswered: "Object variable or with block variable not set
This is some code to allow a meeting request be sent from within an Access database.
The first section up to "##########' works fine and it will be added to your own calendar (based on a form and table elsewhere in the DB.)
Why is it that my code shown here constantly comes up with "object variable or with block variable not set" I think it is because I need to declare a set of oRecipt just under the Dim oRecipt as Outlook.Recipient
but I can't seem to format it without type mismatchs, etc.
the original code for this came from Microsoft Q313789 but this is based around building an actual VB app, as opposed to VB code within Access. I basically need to conversion. Any ideas?...or does anyone know of snippet of code available to integrate into Access that will do what I want...i.e creating meeting requests from within access for clients/employees within the database.
Option Compare Database
Private Sub AddAppt_Click()
On Error GoTo AddAppt_Err
' Save record first to be sure required fields are filled.
' Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment already added to Microsoft Outlook"
'Add a new appointment.
Dim oApp As Outlook.Application
Dim oAppt As Outlook.AppointmentItem
Set oApp = CreateObject("outlook.application")
Set oAppt = oApp.CreateItem(olAppointmentItem)
.MeetingStatus = olMeeting
.Subject = Me!Appt
.Start = Me!Apptdate & " " & Me!Appttime
.End = Me!Apptdatef & " " & Me!Appttimef
'oAppt.Duration = Me!Apptlength
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = _
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
.BusyStatus = olBusy
.IsOnlineMeeting = False
.AllDayEvent = False
' Add attendees.
Dim oRecipts As Outlook.Recipients
Set oRecipts = oAppt.Recipients
' Add required attendee.
Dim oRecipt As Outlook.Recipient
oRecipt = oRecipts.Add("Test user1") ' TODO:
oRecipt.Type = Outlook.OlMeetingRecipientType.olRequired
' Release the Outlook object variable.
Set oAppt = Nothing
' Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
MsgBox "Appointment Added!"
MsgBox "Error " & Err.Number & vbCrLf & Err.Description