Recipe 16.1 Use the Built-in Smart Tags

16.1.1 Problem

How can I enable a user to scroll through a list of names on a form and launch Outlook's Contacts dialog box, so that the user can add the selected person as a contact?

16.1.2 Solution

You can use the built-in Person smart tag to add or change contact information stored in Microsoft Outlook. The Person smart tag allows you to take the following actions:

  • Send an email message to a contact.

  • Schedule a meeting with a contact.

  • Open and edit a contact's information.

  • Add the name in the control to your list of contacts.

It's very easy to add the Person smart tag to a label, text box, or combo box control on a form by following these steps:

  1. Open frmEmployees in 16-01.mdb in design view, select the FullName text box, and press F4 to bring up the Properties window. Click the Data tab and click to the right of the Smart Tags option to load the Smart Tags dialog box.

  2. Select the Person Name checkbox, as shown in Figure 16-1, and click OK. This will add the following text to the SmartTags option in the dialog box:

Figure 16-1. Adding the Person smart tag to a control on a form
  1. Display the form in form view and click the control where you added the smart tag. The sample application contains a form, frmEmployees, with a smart tag on the Name text box. When you click in the text box, the smart tag icon is displayed, as shown in Figure 16-2.

Figure 16-2. The Person smart tag displayed in form view
  1. Selecting the Add to Contacts option will launch Outlook's new contact window, as shown in Figure 16-3. You can then enter the new contact information for that person.

Figure 16-3. The name displayed in Access is automatically entered for the new contact

16.1.3 Discussion

When you use a smart tag to enter a new contact in Outlook, the entire contents of the control are automatically copied to Outlook. If the form control that has the associated smart tag contains only the last name, then that is what will be copied to Outlook. If you want both the last name and first name copied, then create an expression for the Control Source property:

=[FirstName] & " " & [LastName]

If you are attaching a smart tag to a combo box control, then the data displayed in the combo box will be used, not the data in the bound column.

You can add smart tags to label, text box, and combo box form controls. Smart tags are not supported for reports. In addition, you can add smart tags to the following controls on a Data Access Page:

  • Label

  • Bound Span

  • Text Box

  • Scrolling Text

  • Drop-down List

  • Hyperlink

16.1.4 See Also

For more coverage of working with smart tags in Access 2003, see this MSDN article:

To learn other techniques for working with Outlook, see Recipe 12.8 in Chapter 12.