Skip to content

Exporting Table Information to an Outlook Calender

Here’s a simple procedure for exporting information from a table to an Outlook calendar.

Q:Elizabeth Moeck wants to know if class name and date information stored in an Access table can be exported to an Outlook calendar

A:Here is a simple procedure that does this:

Dim dbs As Database

Dim rst As Recordset

Dim appOutlook As New Outlook.Application

Dim nms As Outlook.NameSpace

Dim flds As Outlook.Folders

Dim fld As Outlook.MAPIFolder

Dim itm As Object

Dim lngCount As Long

Set nms = appOutlook.GetNamespace(“MAPI”)

Set fld = nms.Folders(“Personal Folders”).Folders(“Class Dates”)

Set dbs = CurrentDb

Set rst = dbs.OpenRecordset(“tblClassDates”, dbOpenDynaset)

lngCount = rst.RecordCount

MsgBox lngCount & ” records to transfer to Outlook”

‘Loop through table, exporting each record to Outlook

Do Until rst.EOF

Set itm = fld.Items.Add(“IPM.Appointment”)

itm.Subject = rst!ClassName

itm.Start = rst!ClassDate /p>

itm.Duration = 60

itm.Close (olSave)

rst.MoveNext

ErrorHandlerExit:

Exit Sub

ErrorHandler:

MsgBox “Error No: ” & Err.Number & “; Description: ” & Err.Description

Resume ErrorHandlerExit  





Many users have written to me about my suggestion to Sharon Gurbacki about normalizing her movie database tables (see WAW 2.07).  

Most mentioned that in the very specific example she gave, of searching the movies with Elizabeth Taylor in the Actor #1 or Actor #2 position, the query would work if the criteria were placed on different query rows, creating an OR condition rather than an AND condition.  

I didn’t make that suggestion, because it would have been a “quick fix” that would not have been generally useful.  The original table had 20 positions for actors, and to search for an actor in any of the 20 positions would require a query with 20 OR rows, which would probably result in a “Query Too Complex” error when run.  Normalizing the tables would resolve this problem for all cases.

About this author