PC Review


Reply
Thread Tools Rate Thread

'User-defined type not defined' Error

 
 
=?Utf-8?B?UEpGcnk=?=
Guest
Posts: n/a
 
      31st Jul 2007
I just got a new computer at work and a piece of code that has always worked
is now giving me the 'User-defined type not defined' error. I think it is
because I am am missing a reference library, but I don't know which one. The
point it errors is between the => <=


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 objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
With objAppt
.Start = Date + 1 & " " & Time()
.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 Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If
Set objRecurPattern = .GetRecurrencePattern

With objRecurPattern
.RecurrenceType = olRecursWeekly
.Interval = 1
'Once per week
'You can hard-wire in these dates or get the
'information from text boxes, as used here.
'.PatternStartDate = #12/1/2003#
.PatternStartDate = Me!ApptStartDate
'.PatternEndDate = #12/30/2003#
.PatternEndDate = Me!ApptEndDate
End With
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If
'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 "Ok, I have just scheduled a meeting between you and Mr. Mark
Johnson, President of Wyndham Consumer Finance. You can explain to him why
you cannot follow a simple direction.", vbOKOnly, "You're so hosed..."
Exit Sub
Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub

Thoughts?

Thanks in advance!
PJ
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      31st Jul 2007
Presumably the Outlook library. Look for Microsoft Outlook n.0 Object
Library, where n should be 8 for Outlook 97, 9 for Outlook 2000, 10 for
Outlook 2002, 11 for Outlook 2003 and 12 for Outlook 2007.

Another alternative is to use Late Binding, which means you don't have to
set a reference.

Change

Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

to

Dim objOutlook As Object
Dim objAppt As Object
Dim objRecurPattern As Object

and define all of the intrinsic Outlook constants you're using:

Const olAppointmentItem As Long = 1
Const olRecursWeekly As Long = 1
Const olSave As Long = 0

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"PJFry" <(E-Mail Removed)> wrote in message
news:EBC018E6-042F-4A92-B11C-(E-Mail Removed)...
>I just got a new computer at work and a piece of code that has always
>worked
> is now giving me the 'User-defined type not defined' error. I think it is
> because I am am missing a reference library, but I don't know which one.
> The
> point it errors is between the => <=
>
>
> 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 objAppt As Outlook.AppointmentItem
> Dim objRecurPattern As Outlook.RecurrencePattern
> Set objOutlook = CreateObject("Outlook.Application")
> Set objAppt = objOutlook.CreateItem(olAppointmentItem)
> With objAppt
> .Start = Date + 1 & " " & Time()
> .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 Me!ApptReminder Then
> .ReminderMinutesBeforeStart = Me!ReminderMinutes
> .ReminderSet = True
> End If
> Set objRecurPattern = .GetRecurrencePattern
>
> With objRecurPattern
> .RecurrenceType = olRecursWeekly
> .Interval = 1
> 'Once per week
> 'You can hard-wire in these dates or get the
> 'information from text boxes, as used here.
> '.PatternStartDate = #12/1/2003#
> .PatternStartDate = Me!ApptStartDate
> '.PatternEndDate = #12/30/2003#
> .PatternEndDate = Me!ApptEndDate
> End With
> .Save
> .Close (olSave)
> End With
> 'Release the AppointmentItem object variable.
> Set objAppt = Nothing
> End If
> '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 "Ok, I have just scheduled a meeting between you and Mr. Mark
> Johnson, President of Wyndham Consumer Finance. You can explain to him
> why
> you cannot follow a simple direction.", vbOKOnly, "You're so hosed..."
> Exit Sub
> Add_Err:
> MsgBox "Error " & Err.Number & vbCrLf & Err.Description
> Exit Sub
> End Sub
>
> Thoughts?
>
> Thanks in advance!
> PJ



 
Reply With Quote
 
=?Utf-8?B?UEpGcnk=?=
Guest
Posts: n/a
 
      31st Jul 2007
It as the Outlook 11 Object Library.

Thanks for the other method too. Can't have too many...

"Douglas J. Steele" wrote:

> Presumably the Outlook library. Look for Microsoft Outlook n.0 Object
> Library, where n should be 8 for Outlook 97, 9 for Outlook 2000, 10 for
> Outlook 2002, 11 for Outlook 2003 and 12 for Outlook 2007.
>
> Another alternative is to use Late Binding, which means you don't have to
> set a reference.
>
> Change
>
> Dim objOutlook As Outlook.Application
> Dim objAppt As Outlook.AppointmentItem
> Dim objRecurPattern As Outlook.RecurrencePattern
>
> to
>
> Dim objOutlook As Object
> Dim objAppt As Object
> Dim objRecurPattern As Object
>
> and define all of the intrinsic Outlook constants you're using:
>
> Const olAppointmentItem As Long = 1
> Const olRecursWeekly As Long = 1
> Const olSave As Long = 0
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "PJFry" <(E-Mail Removed)> wrote in message
> news:EBC018E6-042F-4A92-B11C-(E-Mail Removed)...
> >I just got a new computer at work and a piece of code that has always
> >worked
> > is now giving me the 'User-defined type not defined' error. I think it is
> > because I am am missing a reference library, but I don't know which one.
> > The
> > point it errors is between the => <=
> >
> >
> > 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 objAppt As Outlook.AppointmentItem
> > Dim objRecurPattern As Outlook.RecurrencePattern
> > Set objOutlook = CreateObject("Outlook.Application")
> > Set objAppt = objOutlook.CreateItem(olAppointmentItem)
> > With objAppt
> > .Start = Date + 1 & " " & Time()
> > .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 Me!ApptReminder Then
> > .ReminderMinutesBeforeStart = Me!ReminderMinutes
> > .ReminderSet = True
> > End If
> > Set objRecurPattern = .GetRecurrencePattern
> >
> > With objRecurPattern
> > .RecurrenceType = olRecursWeekly
> > .Interval = 1
> > 'Once per week
> > 'You can hard-wire in these dates or get the
> > 'information from text boxes, as used here.
> > '.PatternStartDate = #12/1/2003#
> > .PatternStartDate = Me!ApptStartDate
> > '.PatternEndDate = #12/30/2003#
> > .PatternEndDate = Me!ApptEndDate
> > End With
> > .Save
> > .Close (olSave)
> > End With
> > 'Release the AppointmentItem object variable.
> > Set objAppt = Nothing
> > End If
> > '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 "Ok, I have just scheduled a meeting between you and Mr. Mark
> > Johnson, President of Wyndham Consumer Finance. You can explain to him
> > why
> > you cannot follow a simple direction.", vbOKOnly, "You're so hosed..."
> > Exit Sub
> > Add_Err:
> > MsgBox "Error " & Err.Number & vbCrLf & Err.Description
> > Exit Sub
> > End Sub
> >
> > Thoughts?
> >
> > Thanks in advance!
> > PJ

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      31st Jul 2007
If you're going to be pushing your application out to multiple users, and
you can't be sure of which version of Outlook they'll have installed, you
definitely should use Late Binding.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"PJFry" <(E-Mail Removed)> wrote in message
news:F9D779DB-B2E0-4531-844E-(E-Mail Removed)...
> It as the Outlook 11 Object Library.
>
> Thanks for the other method too. Can't have too many...
>
> "Douglas J. Steele" wrote:
>
>> Presumably the Outlook library. Look for Microsoft Outlook n.0 Object
>> Library, where n should be 8 for Outlook 97, 9 for Outlook 2000, 10 for
>> Outlook 2002, 11 for Outlook 2003 and 12 for Outlook 2007.
>>
>> Another alternative is to use Late Binding, which means you don't have to
>> set a reference.
>>
>> Change
>>
>> Dim objOutlook As Outlook.Application
>> Dim objAppt As Outlook.AppointmentItem
>> Dim objRecurPattern As Outlook.RecurrencePattern
>>
>> to
>>
>> Dim objOutlook As Object
>> Dim objAppt As Object
>> Dim objRecurPattern As Object
>>
>> and define all of the intrinsic Outlook constants you're using:
>>
>> Const olAppointmentItem As Long = 1
>> Const olRecursWeekly As Long = 1
>> Const olSave As Long = 0
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "PJFry" <(E-Mail Removed)> wrote in message
>> news:EBC018E6-042F-4A92-B11C-(E-Mail Removed)...
>> >I just got a new computer at work and a piece of code that has always
>> >worked
>> > is now giving me the 'User-defined type not defined' error. I think it
>> > is
>> > because I am am missing a reference library, but I don't know which
>> > one.
>> > The
>> > point it errors is between the => <=
>> >
>> >
>> > 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 objAppt As Outlook.AppointmentItem
>> > Dim objRecurPattern As Outlook.RecurrencePattern
>> > Set objOutlook = CreateObject("Outlook.Application")
>> > Set objAppt = objOutlook.CreateItem(olAppointmentItem)
>> > With objAppt
>> > .Start = Date + 1 & " " & Time()
>> > .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 Me!ApptReminder Then
>> > .ReminderMinutesBeforeStart = Me!ReminderMinutes
>> > .ReminderSet = True
>> > End If
>> > Set objRecurPattern = .GetRecurrencePattern
>> >
>> > With objRecurPattern
>> > .RecurrenceType = olRecursWeekly
>> > .Interval = 1
>> > 'Once per week
>> > 'You can hard-wire in these dates or get the
>> > 'information from text boxes, as used here.
>> > '.PatternStartDate = #12/1/2003#
>> > .PatternStartDate = Me!ApptStartDate
>> > '.PatternEndDate = #12/30/2003#
>> > .PatternEndDate = Me!ApptEndDate
>> > End With
>> > .Save
>> > .Close (olSave)
>> > End With
>> > 'Release the AppointmentItem object variable.
>> > Set objAppt = Nothing
>> > End If
>> > '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 "Ok, I have just scheduled a meeting between you and Mr. Mark
>> > Johnson, President of Wyndham Consumer Finance. You can explain to him
>> > why
>> > you cannot follow a simple direction.", vbOKOnly, "You're so hosed..."
>> > Exit Sub
>> > Add_Err:
>> > MsgBox "Error " & Err.Number & vbCrLf & Err.Description
>> > Exit Sub
>> > End Sub
>> >
>> > Thoughts?
>> >
>> > Thanks in advance!
>> > PJ

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help --> Compile Error - User defined type not defined FatMan Microsoft Access VBA Modules 2 5th Feb 2009 07:25 PM
Compile Error - User Defined Type not defined =?Utf-8?B?Q2h1Y2tX?= Microsoft Access Forms 1 12th Nov 2007 05:46 PM
Compile error: User-defined type not defined Stapes Microsoft Access 4 7th Mar 2007 09:14 PM
User defined type not defined error in mail merge from Access 2003 Caroline Higson Microsoft Access 1 2nd Nov 2006 03:44 PM
Compile error - User defined type not defined ChuckW Microsoft Access Form Coding 1 26th Feb 2005 11:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:24 PM.