Advanced: Requires expert coding, interoperability, and multiuser skills.
- Start Microsoft Access, and then create a new database named Appt.mdb.
- Use the following information to create a new table named tblAppointments:
Field Name Data Type Field Size Format Default Required Appt Text 50 Yes ApptDate Date/Time Short Date Yes ApptTime Date/Time Medium Time Yes ApptLength Number Long Integer 15 Yes ApptNotes Memo No ApptLocation Text 50 No ApptReminder Yes/No No ReminderMinutes Number Long Integer 15 No AddedToOutlook Yes/No No
- Set the ApptDate and ApptTime fields as the composite primary key. Close and save the table as tblAppointments.
NOTE: In this example, the primary key in the appointment table is made up of the appointment date and time fields. You can remove or change the primary key if you want to be able to add multiple appointments for the same date and time.
- Use the AutoForm: Columnar Wizard to create a new form that is based on tblAppointments table, and then save the form as frmAppointments.
- Open the frmAppointments form in Design view, and then change the following form properties:
Caption: Appointment Form
- Add a command button to the form header section, and then set the following properties:
Caption: Send to Outlook
OnClick: [Event Procedure]
- Set the OnClick property of the command button to the following event procedure:
Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err
'Save record first to be sure required fields are filled.
'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft Outlook"
'Add a new appointment.
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Application")
Set objAppt = objOutlook.CreateItem(olAppointmentItem)
.Start = Me!ApptDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt
If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location = Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
Set objRecurPattern = .GetRecurrencePattern
.RecurrenceType = olRecursWeekly
.Interval = 1
'Once per week
.PatternStartDate = #7/9/2003#
'You could get these values
'from new text boxes on the form.
.PatternEndDate = #7/23/2003#
'Release the AppointmentItem object variable.
Set objAppt = Nothing
'Release the Outlook object variable.
Set objOutlook = Nothing
'Set the AddedToOutlook flag, save the record, display a message.
Me!AddedToOutlook = True
MsgBox "Appointment Added!"
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
- On the Tools menu, click References.
- In the References dialog box, click to select the Microsoft Outlook 9.0 Object Library check box. If a reference for this library does not appear in the list, click Browse to locate the Msoutl9.olb file. This file is installed by default in the C:\Program Files\Microsoft Office\Office folder. Click OK to close the References dialog box.
- Save the form as frmAppointments, open it in Form view, and then add the following information as a new appointment record:
NOTE: Enter ApptLength in minutes, not in hours. Note that in this example, ApptLength is set to 120 minutes instead of to 2 hours.
Appt: Budget Meeting
ApptDate: <enter tomorrow's date>
ApptTime: 2:00 PM
ApptNotes: To begin discussion of next year's budget.
ApptLocation: Conference Room
ApptReminder: <check the box>
- Click Send To Outlook, start Microsoft Outlook, and view your calendar for tomorrow's appointments.
ID d'article : 209963 - Dernière mise à jour : 23 juin 2005 - Révision : 1