Access.2007.VBA.Bibl..

(John Hannent) #1
Dim strPriority As String
Dim lngPriority As Long
Dim strDescription As String

Set appOutlook = GetObject(, “Outlook.Application”)
Set nms = appOutlook.GetNamespace(“MAPI”)
Set fldTasks = nms.GetDefaultFolder(olFolderTasks)
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblTasks”)

With rst
Do While Not .EOF

Check that there is a task subject.

strTaskName = Nz(![Title])
Debug.Print “Task: “ & strTaskName
If strTaskName = “” Then
GoTo NextTask
End If

Check for valid dates, and convert blank dates into 1/1/4501 (that is a blank date in Outlook).

If IsNull(![Start Date]) = True Then
dteStartDate = #1/1/4501#
Else
dteStartDate = Nz(![Start Date])
End If

If IsNull(![Due Date]) = True Then
dteDueDate = #1/1/4501#
Else
dteDueDate = Nz(![Due Date])
End If

Convert the text Status value to a number for Outlook.

strStatus = Nz(![Status])
lngStatus = Switch(strStatus = “Not started”, _
0, strStatus = “In progress”, 1, _
strStatus = “Completed”, 2, _
strStatus = “Waiting on someone else”, 3, _
strStatus = “Deferred”, 4, _
“”, 0)

Part II Writing VBA Code to Exchange Data between Office Components

Free download pdf