Outlook.Application "User-defined type not defined"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyWaterloo
    New Member
    • Dec 2007
    • 135

    Outlook.Application "User-defined type not defined"

    Hi,

    I am currently using this code I found on the internet to send an appointment to Outlook:
    Code:
    orm_frmAppointments!ApptDate = [Form_Maintenance Subform3]![Next Maintenance]
    'Form_frmAppointments!ApptTime = Me![Sample Run Time]
    Form_frmAppointments!Appt = "BacT" & " " & Me![Combo100] & " " & "Remove from Incubator at " & Me![Sample Run Time] & " " & Me![Sample Run Date] + 1
    Form_frmAppointments!ApptReminder = True
    
    
    
    ' Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord
    ' Exit the procedure if appointment has been added to Outlook.
    'If Form_frmAppointments!AddedToOutlook = True Then
    If Me!Outlook = True Then
    MsgBox "This appointment has already been added to Microsoft Outlook"
    Exit Sub
    ' Add a new appointment.
    Else
    Dim outobj As Outlook.Application
    Dim outappt As Outlook.AppointmentItem
    Set outobj = CreateObject("outlook.application")
    Set outappt = outobj.CreateItem(olAppointmentItem)
    With outappt
    .Start = Form_frmAppointments!ApptDate & " " & Form_frmAppointments!ApptTime
    .Duration = Form_frmAppointments!ApptLength
    .Subject = Form_frmAppointments!Appt
    .Categories = "Important"
    If Not IsNull(Form_frmAppointments!ApptNotes) Then .Body = Form_frmAppointments!ApptNotes
    If Not IsNull(Form_frmAppointments!ApptLocation) Then .Location = _
    Form_frmAppointments!ApptLocation
    If Form_frmAppointments!ApptReminder Then
    .ReminderMinutesBeforeStart = Form_frmAppointments!ReminderMinutes
    .ReminderSet = True
    End If
    .Save
    End With
    End If
    ' Release the Outlook object variable.
    Set outobj = Nothing
    ' Set the AddedToOutlook flag, save the record, display a message.
    Form_frmAppointments!AddedToOutlook = True
    Me!Outlook = True
    DoCmd.RunCommand acCmdSaveRecord
    MsgBox "Appointment Added!"
    Exit Sub
    AddAppt_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Exit Sub
    I have copied the code to another database project I am working on. In this new database the code is giving an error and I don't know why. The error takes place on line #17. I get the "User-defined type not defined" error. This code works great in my other database so I am wondering if there is something else I need to do that I just can't remember to get it to work right in the new database. Any ideas?
  • MyWaterloo
    New Member
    • Dec 2007
    • 135

    #2
    Never mind. I didn't have a reference set to the Microsoft Outlook Object Library. I thought I did but guess not.

    Comment

    Working...