Insert a hyperlink

When you design a Microsoft Office InfoPath 2003 form template, there are three ways to incorporate hyperlinks into your design.

What do you want to do?

Create a static hyperlink in a form template

Create a dynamic hyperlink in a form template

Allow users to create their own hyperlinks

Create a static hyperlink in a form template

Use this technique when you want to include a specific hyperlink in your form template. Users cannot edit this hyperlink when they fill out the form.

  1. In design mode, click in the form template where you want to insert a hyperlink, or select the text or picture that you want to turn into a hyperlink.
  2. On the Standard toolbar, click Insert Hyperlink Button image.
  3. In the Address box, type the URL that you want to link to.
  4. To change the hyperlink text that appears on the form template, type the text that you want in the Text box.

 Note   If you selected a picture in step 1, this option is unavailable.

  1. To assign a ScreenTip that will appear when a user rests the mouse pointer over the hyperlink, click the Advanced tab, and then, in the ScreenTip box, type the text that you want to display.

Tip     To quickly insert a static hyperlink, you can type a Web site address (such as www.example.com), a file location, or an e-mail address directly in the form template. When you enter a space after the text that you typed, InfoPath formats that text as a blue, underlined hyperlink. To automatically create a hyperlink for text that includes spaces, enclose the phrase in quotation marks ("). For example, to link to a file that contains spaces in its file name, type "http://www.example.com/file name.htm", and then press ENTER.

Top of Page Top of Page

Create a dynamic hyperlink in a form template

If you want a hyperlink to change depending on values in the form, you can include a dynamic hyperlink in your form template. To create this type of hyperlink, you must bind (bind: To connect a control to a field or group in the data source so that data entered into the control is saved. When a control is unbound, it is not connected to a field or group, and so data entered into the control will not be saved.) the hyperlink to a field (field: An element or attribute in the data source that can contain data. If the field is an element, it can contain attribute fields. Fields store the data that is entered into controls.) in the data source (data source: The collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the data source.). If the design of your form requires it, you can bind the hyperlink to one field and the display text to another field.

For example, imagine that you are designing a real-estate listing form, which is connected to a database that contains information about properties that are for sale. In the database, you might have a field that contains distinct URLs for each real estate agent. In your real-estate listing form, you can insert a hyperlink and bind it to the field in the data source that contains the URL value. If you want the hyperlink to display the name of the real estate agent rather than the URL, you can bind its display text to a field in the data source that contains the name value. When users click the agent's name on the form, that agent's Web page opens in a browser window.

  1. In design mode, click in the form template where you want to insert a hyperlink, or select the text or picture that you want to turn into a hyperlink.
  2. On the Standard toolbar, click Insert Hyperlink Button image.
  3. Under Link to on the General tab, select Data source, click Select XPath Button image, and then select a field or group.
  4. Under Display, do one of the following:
    • To display a specific string of text for the hyperlink, click Text, and then in the Text box, type the text that you want to display.
    • To have a value inside a control on the form template display as the hyperlink's text, click Data source, click Select XPath Button image, and then select the field or group that the control is bound to.
  5. To assign a ScreenTip that will appear when a user rests the mouse pointer over the hyperlink, click the Advanced tab, and then, in the ScreenTip box, type the text that you want to display.

Tip    You can use XPath (XML Path Language (XPath): A language used to address parts of an XML document. XPath also provides basic facilities for manipulation of strings, numbers, and Booleans.) expressions to create hyperlinks that are a combination of static and dynamic data. For example, imagine that you want to create a hyperlink that links to "http://www.example.com/my name.html" where the Web server name, http://www.example.com, doesn't change, but the file name, my name, varies depending on the data that users type into a specific field in the form. In this case, you would type concat('http://www.example.com/', my:name, '.html') in the Data source box, where my:name is the name of the field to which the text box is bound. The Concat function allows you to combine static text with data from other fields in the form.

Top of Page Top of Page

Allow users to create their own hyperlinks

If you want to allow users to add their own hyperlinks when they fill out a form based on your form template, you can insert a rich text box into your form template. Users can then insert hyperlinks into the rich text box, either by typing the appropriate text followed by a space, or by clicking Hyperlink on the Insert menu. The rich text box is the only control that accepts user-defined hyperlinks. When users place their insertion point inside any other control, the Hyperlink command appears dimmed.

  1. On the Insert menu, click More Controls.
  2. Under Insert controls in the Controls task pane, click Rich Text Box.
  3. To adjust the size of the rich text box, select it in the form template, and then drag the borders of the box to the size that you want.
  4. To test that everything works as you expect, click Preview Form on the Standard toolbar, and then in the preview window, type a URL in the rich text box followed by a space. The URL should automatically be formatted as a blue, underlined hyperlink.

Top of Page Top of Page

 
 
Applies to:
InfoPath 2003