Compile Error

  • Thread starter Thread starter pmallick
  • Start date Start date
P

pmallick

Hello,

I am running code from a button that was working perfectly until just
recently.
Now I am getting a Complie Error - User-defined type not defined.
I just cant figure this out.
The button sends a task to a user and also sends a report by email.
Can anyone help??
My code is..


Private Sub SubmitActionItem_Click()
'Refresh the current data.'
DoCmd.RunCommand acCmdRefresh

Dim myOlApp As New Outlook.Application
Dim myItem As Outlook.Outlook.TaskRequestItem
Dim myDelegate As Outlook.Recipient
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add(DLookup("", "Users",
"[ID]=Forms!ActionItem!AssignedTo "))
myDelegate.Resolve
Call fOSUserName
If myDelegate = fOSUserName And myDelegate.Resolved Then
myItem.Subject = "Action Item " & Me!ActionID & " Assigned To " &
Me!AssignedTo.Column(1)
myItem.Body = Me!ActionItemDetails
myItem.DueDate = Me!DueDate
myItem.ReminderSet = False
myItem.Save
Else
myItem.Subject = "Action Item " & Me!ActionID & " Assigned To " &
Me!AssignedTo.Column(1)
myItem.Body = Me!ActionItemDetails
myItem.DueDate = Me!DueDate
myItem.ReminderSet = False
myItem.Display
myItem.Send
myItem.Save

End If

DoCmd.OpenReport "ActionItem", acViewPreview, "",
"[ActionID]=[Forms]![ActionItem]![ActionID]", acHidden
Dim sAddress1 As String
sAddress1 = DLookup("[Email]", "Users",
"[ID]=Forms!ActionItem!AssignedTo ")

DoCmd.SendObject acReport, "ActionItem", "PDFFormat(*.pdf)",
sAddress1, , , "Action Item " & [ActionID] & " - Jandakot Airport Holdings",
"Please see the attached Action Item - Number " & [ActionID] & " you have
been assigned to implement.", False, ""

Me!SentDate = Date

DoCmd.Close acReport, "ActionItem"
DoCmd.Close acForm, "ActionItem"
Beep
MsgBox "This Action Item has been sent to the nominated person.",
vbInformation, "Thankyou"


SubmitActionItem_Report_Exit:
Exit Sub

SubmitActionItem_Report_Err:
MsgBox Error$

End Sub
 
You don't say on which line the error occurs.
If you don't know, then you need to run the code in debug mode and step
through it.
 
Hi Dave,

The error is in the following line
Dim myOlApp As New Outlook.Application

Any ideas.

thanks
Pauline


Klatuu said:
You don't say on which line the error occurs.
If you don't know, then you need to run the code in debug mode and step
through it.
--
Dave Hargis, Microsoft Access MVP


pmallick said:
Hello,

I am running code from a button that was working perfectly until just
recently.
Now I am getting a Complie Error - User-defined type not defined.
I just cant figure this out.
The button sends a task to a user and also sends a report by email.
Can anyone help??
My code is..


Private Sub SubmitActionItem_Click()
'Refresh the current data.'
DoCmd.RunCommand acCmdRefresh

Dim myOlApp As New Outlook.Application
Dim myItem As Outlook.Outlook.TaskRequestItem
Dim myDelegate As Outlook.Recipient
Set myItem = myOlApp.CreateItem(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add(DLookup("", "Users",
"[ID]=Forms!ActionItem!AssignedTo "))
myDelegate.Resolve
Call fOSUserName
If myDelegate = fOSUserName And myDelegate.Resolved Then
myItem.Subject = "Action Item " & Me!ActionID & " Assigned To " &
Me!AssignedTo.Column(1)
myItem.Body = Me!ActionItemDetails
myItem.DueDate = Me!DueDate
myItem.ReminderSet = False
myItem.Save
Else
myItem.Subject = "Action Item " & Me!ActionID & " Assigned To " &
Me!AssignedTo.Column(1)
myItem.Body = Me!ActionItemDetails
myItem.DueDate = Me!DueDate
myItem.ReminderSet = False
myItem.Display
myItem.Send
myItem.Save

End If

DoCmd.OpenReport "ActionItem", acViewPreview, "",
"[ActionID]=[Forms]![ActionItem]![ActionID]", acHidden
Dim sAddress1 As String
sAddress1 = DLookup("[Email]", "Users",
"[ID]=Forms!ActionItem!AssignedTo ")

DoCmd.SendObject acReport, "ActionItem", "PDFFormat(*.pdf)",
sAddress1, , , "Action Item " & [ActionID] & " - Jandakot Airport Holdings",
"Please see the attached Action Item - Number " & [ActionID] & " you have
been assigned to implement.", False, ""

Me!SentDate = Date

DoCmd.Close acReport, "ActionItem"
DoCmd.Close acForm, "ActionItem"
Beep
MsgBox "This Action Item has been sent to the nominated person.",
vbInformation, "Thankyou"


SubmitActionItem_Report_Exit:
Exit Sub

SubmitActionItem_Report_Err:
MsgBox Error$

End Sub
[/QUOTE][/QUOTE]
 
Back
Top