Programming Microsoft Access 2000 (Microsoft Programming Series)

In Chapter 5, you learned how to use hyperlinks to navigate around forms in a custom application. This is only a small portion of the functionality that hyperlinks can deliver. You can also navigate to other Access databases, to bookmarks in a Word document, or to intranet and Internet URLs. You can even use hyperlinks to open your e-mail software (such as Microsoft Outlook) with the address of a specific individual and a designated subject.

Types of Hyperlinks

Hyperlinks can appear as labels, command buttons, and unbound image controls on forms, reports, and data access pages. You can also create bound hyperlinks so that a table can contain a set of hyperlinks. You can assign a unique hyperlink to each record in a table. One obvious use for this is associating a URL with each record entity (for example, companies). After following either a bound or unbound hyperlink, you can use the Back control on the Office Web or browser toolbar to navigate back from a hyperlink target address to Access.

The Hyperlink Data Type

When you use bound hyperlinks, your application specifies the Hyperlink data type, which can contain up to four parts, each delimited by the number (#) sign. The display text part appears first if you specify it. This text appears in place of the address to which a hyperlink navigates. For example, instead of a hyperlink showing the address for the Microsoft Web site, it can say simply Microsoft.

The second part is the address—the URL or UNC address for a target file. The address can be absolute or relative. It is common at Web sites to specify hyperlinks relatively. In Access, a relative address extends from the Hyperlink Base setting in an Access file. You can examine this setting by choosing the Database Properties command from the File menu in the database window.

The third part is the subaddress, which names a part of a file to navigate to. The parts you can navigate to vary by Office component. In Access, you can navigate to database objects, such as forms, reports, tables, and queries. You can specify a database object type, such as table, and the name of a specific object, such as Customers. You do not have to specify an object type, but if a database contains multiple objects with the same name, Access navigates to them in an arbitrary order. If a hyperlink includes both address and subaddress parts, the link navigates to another file. If the address part is missing, the link navigates to an object in the current database.

The fourth part, a screen tip, is new in Access 2000. This text appears when you rest the cursor over a hyperlink. It can offer a reminder about the purpose of a hyperlink. These tips appear in hyperlinks on pages viewed with Internet Explorer 4 and later. They also appear in Access 2000 custom applications.

Inserting and Editing Hyperlinks

While you can type a new hyperlink address, it is simpler and safer to use the Insert Hyperlink tool or its corresponding menu command. You can invoke the Insert Hyperlink command from any point at which you can add a hyperlink to a document. For example, you can choose Insert Hyperlink from the Design view of a form to add a hyperlink as a label. You can give a command button navigational abilities by clicking the Build button next to its Hyperlink Address or Hyperlink SubAddress properties. You can assign navigational capabilities to an image in the same way.

All these actions open the Insert Hyperlink dialog box. Figure 13-6 shows this dialog box for creating a label hyperlink on a form. The label's caption value is the ASP sample at the fictional Programming Microsoft Access site, whose URL is http://samples.microsoft.com/telelookup.com. Click ScreenTip to open a second dialog box for entering text for the screen tip associated with the hyperlink.

Figure 13-6. The Insert Hyperlink dialog box for a URL.

You can click the E-mail Address button on the Option bar to open the version of the dialog box for e-mail. (See Figure 13-7.) The dialog box automatically inserts the mailto protocol prefix to invoke a workstation's default e-mail package from a browser. You can also specify the recipient and the subject. Just as you can select from sites previously visited when you assign a hyperlink address, you can select a previously entered e-mail address and subject. The hyperlink that Figure 13-7 creates displays the phrase mail the prez. When a user clicks this phrase, it opens the user's e-mail software with the recipient rickd@cabinc.net and with the scoop as the subject.

Figure 13-7. The Insert Hyperlink dialog box for an e-mail message.

After you insert a hyperlink in an application, you can right-click it and choose Hyperlink from the shortcut menu to see an array of options for processing existing hyperlinks. The Edit Hyperlink command is the most obvious choice for revising a hyperlink. This opens the Edit Hyperlink dialog box, which has the same layout as the Insert Hyperlink dialog box. You can use it to update any of the hyperlink fields. Over time, you might have to fine-tune the display text or the URL for a hyperlink. Similarly, you can add to the recipient list for links that send e-mail so that messages route to more recipients directly.

Hyperlink Samples

One of the most popular pages at many Web sites is the Favorites page, which points to sites that the author finds valuable or interesting. You can insert similar pages in your custom Access solutions. Such sites can include e-mail or Web links to your business and can include site addresses with free or low-cost technical support.

Figure 13-8 shows a Favorites page that is an Access form with two images and two labels. All four serve as hyperlinks. The first image is my company's logo. If users with a live connection to the Internet click the image, Access takes them to my firm's Web site. The second image is a Microsoft Access logo, which takes users to the Access site within the Microsoft site. The two label hyperlinks open e-mail links to employees of my firm.

Figure 13-8. A Favorites page with two images and two labels that serve as hyperlinks.

Figure 13-9 shows a form with a bound hyperlink that is based on a table of hyperlinks. The table appears below the form in the figure. The screen tip, CAB Headquarters, appears for the first hyperlink. The bottom display presents that hyperlink in Edit mode, which exposes the hyperlink parts. Notice that there is display text and an address part, but no subaddress. The hyperlink concludes with the screen tip text.

Figure 13-9. The form with a bound hyperlink shows a screen tip for the first hyperlink in the table. The table exposes the full syntax for the first hyperlink.

Категории