Access.2007.VBA.Bibl..

(John Hannent) #1
If you store email addresses in a table of contacts, customers, or clients, you can use VBA code to cre-
ate emails to them from an Access form, either to a single recipient or a group of recipients, without
having to switch to Outlook.

Contacts are another matter — although Outlook has a Contacts component, with many useful fea-
tures (especially the link to email), nevertheless, Outlook contacts are deficient in one very impor-
tant feature when compared to Access: All Outlook data is stored in a flat-file MAPI table, so you
can’t set up one-to-many relationships between (for example) companies and contacts, or contacts
and phone numbers. If a company moves to another location or changes its name, you have to make
the change manually in each contact for that company; if a contact has more than three addresses,
or a phone number that doesn’t fit into one of the available categories, you are out of luck.

For contacts, you really need both the attractive interface and built-in email connectivity of
Outlook contacts, and the relational database capabilities of Access. This means you need a way to
synchronize data between Outlook and Access contacts; my Synchronizing Contacts.accdb data-
base does just this.

See Chapter 11 for a discussion of the Synchronizing Contacts database. Chapter 8
deals with exporting and importing contacts without synchronization.

This chapter concentrates on exporting tasks, appointments, and journal items from Access to
Outlook and creating emails to contacts stored in an Access table.

The sample database for this chapter is Access to Outlook.accdb.

Exporting Appointments and Tasks to Outlook ..................................................................


If you have an Access table of employee, contact, or customer information, you may need to create
Outlook appointments or tasks based on information in the table records. The tblEmployees table
in the sample database has two employee review date fields: LastReviewDate and NextReviewDate.
Figure 4.1 shows the frmEmployees form, which is bound to this table.

The next employee review can be scheduled by entering a date in the Next Review Date field and then
clicking the Schedule Appointment button. Code on the BeforeUpdateevent of txtNextReviewDate
(listed next) checks that the date entered (or selected using the Calendar pop-up) is a Tuesday or
Thursday (the assumption is that employee reviews are only done on those days):

Private Sub txtNextReviewDate_BeforeUpdate(Cancel As Integer)

On Error GoTo ErrorHandler

Dim strWeekday As String
Dim intWeekday As Integer

NOTENOTE


CROCROSSSS-REF-REF


Part I The Office Components and What They Do Best

Free download pdf