Send Outlook object from Access

R

RTimberlake

I need to be able to send an Outlook task from an Access from. The code I
have tried is not working. I am currently using this code:

Private Sub SendTask_Click()
Function fncAddOutlookTask()
Dim OutlookApp As Outlook.Application
Dim OUtlookTask As Outlook.TaskItem

Set OutlookApp = CreateObject
Set OUtlookTask = OutlookApp.CreateItem

End Function
End Sub


When I try this I get an error: Complie error - Expected End Sub.

Please help.
 
O

Ofer Cohen

You have called a function within the Sub,

' Sub Call
Private Sub SendTask_Click()

Function Call
Function fncAddOutlookTask()

Dim OutlookApp As Outlook.Application
Dim OUtlookTask As Outlook.TaskItem

Set OutlookApp = CreateObject
Set OUtlookTask = OutlookApp.CreateItem


End Function

End Sub

=======================
either remove the function call
Private Sub SendTask_Click()
Dim OutlookApp As Outlook.Application
Dim OUtlookTask As Outlook.TaskItem

Set OutlookApp = CreateObject
Set OUtlookTask = OutlookApp.CreateItem

End Sub
==================
Or, create the function, and then call it from the Sub

'The function
Function fncAddOutlookTask()

Dim OutlookApp As Outlook.Application
Dim OUtlookTask As Outlook.TaskItem

Set OutlookApp = CreateObject
Set OUtlookTask = OutlookApp.CreateItem

End Function


' The Sub
Private Sub SendTask_Click()

fncAddOutlookTask

End Sub
 
R

RTimberlake

Ofer,
When I did:
Private Sub SendTask_Click()
Dim OutlookApp As Outlook.Application
Dim OUtlookTask As Outlook.TaskItem

Set OutlookApp = CreateObject
Set OUtlookTask = OutlookApp.CreateItem

End Sub

I received the following error: Argument not optional (The CreateObject
portion was highlighted.)

I then tried calling the function from the sub like you suggested and
nothing happened.

Am I doing soemthing wrong? Is this possible?
Rebecca
 
R

RTimberlake

Your code works great. Now I have one more question. Is there anyway to have
the fields in the Task filled in based on entries on a form? For example. If
I have a form with the following controls: Date_Assigned, Evaluator1 (E-mail
address), Due_Date. Can the entried in these controls be entered into the
Outlook taks automatically?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top