Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(“tblEvents”)
With rst
Do While Not .EOF
Check that there is an appointment subject.
strApptName = Nz(![Title])
Debug.Print “Appointment name: “ & strApptName
If strApptName = “” Then
GoTo NextAppt
End If
Check for valid dates, and convert blank dates into 1/1/4501 (that is a blank date in Outlook).
If IsNull(![Start Time]) = True Then
dteStartTime = #1/1/4501#
Else
dteStartTime = Nz(![Start Time])
End If
If IsNull(![End Time]) = True Then
dteEndTime = #1/1/4501#
Else
dteEndTime = Nz(![End Time])
End If
Create a new appointment item in the local Calendar folder.
Set appt = fldCalendar.Items.Add
appt.Subject = strApptName
appt.Start = dteStartTime
appt.End = dteEndTime
appt.Location = Nz(![Location])
appt.Body = Nz(![Description])
appt.Close (olSave)
NextAppt:
.MoveNext
Loop
End With
MsgBox “Appointments exported to Outlook”
ErrorHandlerExit:
Exit Function
ErrorHandler:
Part II Writing VBA Code to Exchange Data between Office Components