unixkid
01-04-2011, 03:18 PM
need some help with assigning a task in Outlook using Acess.
I want to have the option to be able to assign a task to yourself, however, this cannot be achieved using .assign and .send, therefore I made a table in which all the user information is stored (name and email address)
and then if the user name (which I get usign the environ "username" method) is found within the email address then it does not use the assign method, just the send, and vice versa as you'll see below.
The problem I have is that when it assigns to another user, it sends the email for the task however it enters the persons email address in twice, which then means that I cannot keep track of the changes! Please help!!!
Option Compare Database
Private Sub Task_Click()
On Error GoTo Err_Task_Click
Dim OutlookApp As Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim LDescription As String
Set db = CurrentDb()
LSQL = "select Description from Correspondence"
Set Lrs = db.OpenRecordset(LSQL)
If Lrs.EOF = False Then
LDescription = Lrs("Description")
Else
LDescription = "Not found"
End If
Lrs.Close
Set Lrs = Nothing
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Set myDelegate = OutlookTask.Recipients.Add(Me.Combo16.Column(2))
OutlookTask.Subject = Forms![Tracker]![Description]
OutlookTask.Body = "Tracker Notes:" & " " & Forms![Tracker]![Notes] & Chr(13) & "Tracker ID:" & " " & Forms![Tracker]![ID] & Chr(13) _
& "Reference:" & " " & Forms![Tracker]![Reference] & Chr(13) & Chr(13) & "Path:" & " " & Forms![Tracker]![Path] & Chr(13) _
& Chr(13) & Chr(13) & "Additional Notes: " & Text0.Value
OutlookTask.ReminderSet = True
OutlookTask.ReminderTime = DateAdd("n", 1, Now)
OutlookTask.DueDate = Text2.Value
OutlookTask.ReminderPlaySound = True
OutlookTask.ReminderSoundFile = "C:\Windows\Media\Ding.wav"
If InStr(UCase(OutlookTask.Recipients.Add(Me.Combo16. Column(2))), UCase(Environ("username"))) = 1 Then
OutlookTask.Save
Else
OutlookTask.Assign
OutlookTask.Send
End If
Exit_Task_Click:
Exit Sub
Err_Task_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err = ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_Task_Click
End Sub
I want to have the option to be able to assign a task to yourself, however, this cannot be achieved using .assign and .send, therefore I made a table in which all the user information is stored (name and email address)
and then if the user name (which I get usign the environ "username" method) is found within the email address then it does not use the assign method, just the send, and vice versa as you'll see below.
The problem I have is that when it assigns to another user, it sends the email for the task however it enters the persons email address in twice, which then means that I cannot keep track of the changes! Please help!!!
Option Compare Database
Private Sub Task_Click()
On Error GoTo Err_Task_Click
Dim OutlookApp As Outlook.Application
Dim OutlookTask As Outlook.TaskItem
Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim LDescription As String
Set db = CurrentDb()
LSQL = "select Description from Correspondence"
Set Lrs = db.OpenRecordset(LSQL)
If Lrs.EOF = False Then
LDescription = Lrs("Description")
Else
LDescription = "Not found"
End If
Lrs.Close
Set Lrs = Nothing
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookTask = OutlookApp.CreateItem(olTaskItem)
Set myDelegate = OutlookTask.Recipients.Add(Me.Combo16.Column(2))
OutlookTask.Subject = Forms![Tracker]![Description]
OutlookTask.Body = "Tracker Notes:" & " " & Forms![Tracker]![Notes] & Chr(13) & "Tracker ID:" & " " & Forms![Tracker]![ID] & Chr(13) _
& "Reference:" & " " & Forms![Tracker]![Reference] & Chr(13) & Chr(13) & "Path:" & " " & Forms![Tracker]![Path] & Chr(13) _
& Chr(13) & Chr(13) & "Additional Notes: " & Text0.Value
OutlookTask.ReminderSet = True
OutlookTask.ReminderTime = DateAdd("n", 1, Now)
OutlookTask.DueDate = Text2.Value
OutlookTask.ReminderPlaySound = True
OutlookTask.ReminderSoundFile = "C:\Windows\Media\Ding.wav"
If InStr(UCase(OutlookTask.Recipients.Add(Me.Combo16. Column(2))), UCase(Environ("username"))) = 1 Then
OutlookTask.Save
Else
OutlookTask.Assign
OutlookTask.Send
End If
Exit_Task_Click:
Exit Sub
Err_Task_Click:
If (Err = ERR_OBJNOTEXIST) Or (Err = ERR_OBJNOTSET) Or (Err = ERR_CANTMOVE) Then
Resume Next
End If
MsgBox Err.Description
Resume Exit_Task_Click
End Sub