Crystal Reports in the Real WorldReferencing External Resources


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 query string. By knowing the URL and query string that drive a particular site, a report hyperlink can be customized to open a website 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 Chap6Formatted.rpt or the report you have created in these last exercises. From the Insert menu, choose Text Object. Add the text Map to the report between the customer name and city, as shown in Figure 6.18.

Figure 6.18. A new Map field added to the report provides a dynamic hyperlink directly to maps of the client's locales.


2.

Right-click the newly added text object and choose Format Text. Click the Hyperlink tab, select the Website on the Internet hyperlink option, and click the x+2 button beside the Website Address input box. Figure 6.19 highlights the formula you will enter to provide a dynamic data-driven link to MapQuest maps showing location maps of the client locales. Enter the following code into the Formula Editor:

StringVar URL; // The prefix of the URL that will not change; URL := "http://www.mapquest.com/maps/map.adp?" URL := URL & "searchtype=address&addtohistory=&searchtab=home&address="; // Add the country URL := URL & "&country=" & {Customer.Country}; // Add the state URL := URL & "&state=" & {Customer.Region}; // Add the city URL := URL & "&city=" & {Customer.City}; URL


Figure 6.19. Code that builds a dynamic data-driven URL that will enable hyperlinks to the MapQuest website 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 but you should find that many of the city, region, and country combinations will in fact be successfully received and processed by MapQuest, as shown in Figure 6.20 for a Toronto-based customer. MapQuest.com might open with only partial information, but the concept remains valid.


Figure 6.20. A MapQuest website that has received a dynamic data-driven request directly from your Crystal Report.





Crystal Reports XI(c) Official Guide
Crystal Reports XI Official Guide
ISBN: 0672329174
EAN: 2147483647
Year: N/A
Pages: 365

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net