A very powerful use of hyperlinks is to be able to take advantage of the many resources on the Internet. Many Internet sites make use of what is called a QueryString. By knowing the URL and QueryString that drive a particular site, a report hyperlink can be customized to open a Web site and perform some functionality. In the next example, the address of the sample customers can be opened in MapQuest.com by using a hyperlink:
1. | Start with opening the report Chap6PostFormat.rpt. From the Insert menu, choose Text Object. Add the text MapQuest to the report. |
2. | Right-click the newly added text object and choose Format Tex. Then click the Hyperlink tab and click the x+2 button. See Figure 6.18 for an example of what the formula should look like. Enter the following code into the text: StringVar URL; // The prefix of the URL that will not change; it is hard-coded to the USA URL := "http://www.mapquest.com/maps/map.adp?"; URL := URL & "country=US&countryid=250&adtohistory="; // Add the street address URL := URL & "&address=" & {Customer.Address1}; // Add the city URL := URL & "&city=" & {Customer.City}; // Add the state URL := URL & "&state=" & {Customer.Region}; // Add the ZIP code URL := URL & "&zipcode=" & {Customer.Postal Code}; // Add the suffix of the URL URL := URL & "&submit=Get Map"; URL Figure 6.18. Code that builds a dynamic data driven URL that will enable hyperlinks to the Mapquest Web site from a Crystal Report |
3. | Click Save and Close to close the code window. Click OK to close the Format Editor window. Format the hyperlink using the same method used to format the e-mail address to show the user it is an actionable item. |
NOTE
The sample data does not necessarily use valid addresses. MapQuest.com might open with only partial information, but the concept remains valid.
3.22.41.212