Deleting tasks in Outlook using Access

thebaz67

New member
Local time
Yesterday, 20:10
Joined
Sep 1, 2016
Messages
4
I have run into an issue that I hope can be solved.

I am using code in access to create 4 tasks in Outlook for a team to work on.

I tried to use the mileage field in the tasks to find them quickly since from Access I have a case number but the issue I have run into is that since they are related cases I tried to add decimal points to the mileage for the additional related tasks.

So for case 1 there would be.

task 1 with mileage 1
task 1a with mileage 1.21
task 1b with mileage 1.22
task 1c with mileage 1.23

When I use my code to delete the task when it has been completed in the DB it will remove the first task without the decimal places but it will not remove the tasks with the decimal points.

here is a sample of the code in question:

Private Sub rm_30_day_retaliate_review_Click()

Const olFolderTasks = 13

Dim objOwner As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set NS = objOutlook.GetNamespace("MAPI")

Set objOwner = NS.CreateRecipient("user")
objOwner.Resolve

If objOwner.Resolved Then
MsgBox objOwner.Name
MsgBox NS.CurrentUser
Set newTaskFolder = NS.GetSharedDefaultFolder(objOwner, olFolderTasks)

Set colItems = newTaskFolder.Items

strFilter = "[Mileage] = " & Me.Case_Number + 0.21

MsgBox strFilter

Set colTasks = colItems.Restrict(strFilter)


For Each objTask In colTasks
objTask.Delete
Next

End If


End Sub
 
What I may end up doing is since the case number is embedded in the subject I can use that combination to uniquely identify the different related tasks.

thanks
Basil
 
I'm only guessing here but I would assume once you have created the task in Outlook it is no longer reading 1.21 as a number, but as text.

Maybe you just need to add quotes to your strFilter so its read as text?

strFilter = "[Mileage] = """ & Me.Case_Number + 0.21 & """"

I think that's the right amount of "s :)

Good luck!
 
Thanks I gave that a try and no joy.

I also tried

strFilter = "[Mileage] = " & CStr(Me.Case_Number + 0.21)

to turn the numeric portion to a string and still no joy

I'm only guessing here but I would assume once you have created the task in Outlook it is no longer reading 1.21 as a number, but as text.

Maybe you just need to add quotes to your strFilter so its read as text?

strFilter = "[Mileage] = """ & Me.Case_Number + 0.21 & """"

I think that's the right amount of "s :)

Good luck!
 

Users who are viewing this thread

Back
Top Bottom