Access.2007.VBA.Bibl..

(John Hannent) #1
strTitle
Cancel = True
GoTo ErrorHandlerExit

Case vbTuesday, vbThursday

Date is a Tuesday or Thursday; put up message and continue:

strTitle = “Right day of week”
strPrompt = “Review date OK”
MsgBox strPrompt, vbOKOnly + vbInformation, _
strTitle

End Select

End If

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit

End Sub

To work with Outlook items in code, you need to set a reference to the Outlook object
library (select Tools➪References in the Visual Basic window, as shown in Figure 4.2). To
avoid creating multiple instances of Outlook, I like to use an error handler that will open a new instance
of Outlook using CreateObjectif the GetObjectfunction fails because Outlook is not running.

FIGURE 4.2
Setting a reference to the Outlook object library.

NOTENOTE


Part I The Office Components and What They Do Best

Free download pdf