greeneyerat
Technical User
I have a main form, in which I have a subfrmAppointments that has a control button that is suppose to send the actual appointment to Outlook but I get the following message:
"user defined type not defined" and the following is the code line highlighted.
Dim objOutlookApplication As Outlook.Application
Following is the code I have written:
Private Sub CmdAddAppt_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!ApptAddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook."
Exit Sub
'Add a new appointment.
Else
Dim objOutlookApplication As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
With objAppt
.Start = Me!ApptDate & " " & 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
If Not IsNull(Me!ApptSubject) Then .Subject = Me!ApptSubject
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ApptReminderMin
.ReminderSet = True
End If
objAppt.Save
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If
'Release the Outlook object variable.
Set objOutlook = Nothing
'Set the AddedToOutlook flag, save the record, display a message.
Me!ApptAddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Please Help!!
Thanks!!
"user defined type not defined" and the following is the code line highlighted.
Dim objOutlookApplication As Outlook.Application
Following is the code I have written:
Private Sub CmdAddAppt_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!ApptAddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook."
Exit Sub
'Add a new appointment.
Else
Dim objOutlookApplication As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
With objAppt
.Start = Me!ApptDate & " " & 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
If Not IsNull(Me!ApptSubject) Then .Subject = Me!ApptSubject
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ApptReminderMin
.ReminderSet = True
End If
objAppt.Save
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If
'Release the Outlook object variable.
Set objOutlook = Nothing
'Set the AddedToOutlook flag, save the record, display a message.
Me!ApptAddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"
Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Please Help!!
Thanks!!