Symptom
- You can hyperlink one report to another in Crystal Reports. Is it possible to pass a date value contained in one report to the parameter of the hyperlinked report?
Environment
- Crystal Reports 9
- Crystal Reports 10
- Crystal Reports XI
- Crystal Reports XI R2
- Crystal Reports 2008
- SAP Crystal Reports 2011
- SAP Crystal Reports 2013
Resolution
- In Crystal Reports, you can pass a date value from one report to a parameter of the hyperlinked report either by:
- Creating a hard coded hyperlink with the date value; or
- Creating a dynamic date value formula and passing it through a hyperlink
- Creating a hard coded hyperlink with the date value:
To pass a date value to a parameter through a hyperlink, complete the following:
1. From Crystal Reports, select the field you want to create a hyperlink on.
2. Right-click the field, choose 'Format Field'.
3. On the 'Format Editor', click the 'Hyperlink' tab.
4. Under 'Hyperlink type', click 'A website on the internet'.
5. Under 'Hyperlink information', click 'X+2'.
6. Type a URL similar to the following:
"HTTP://<ServerName>/<VirtualDirectory>/<ReportName.rpt>?prompt0=Date(Year,Month,Day)"
NOTE: =====
· <Server Name> stands for the Server Name
· <Virtual Directory> stands for the full path to where the report is stored
· <Report Name> stands for the report file name
· ?Prompt0=Date(Year,Month,Day) stands for the format used to pass the date value to the parameter. Replace Year, Month, and Day need with actual date values.
For example :
You want to pass the date value June 1, 2001 to a parameter through a hyperlink.
The Server Name is MyServer
The Virtual Directory is Finance/MyReports/
The Report Name is LastYearSales.rpt
The URL to type in the hyperlink is :
"HTTP://MyServer/Finance/MyReports/LastYearSales.rpt /?prompt0=Date(2001,06,01)"
Creating a dynamic date value formula and passing it through a hyperlink
- To pass a dynamic date value to a parameter you need to extract the year, month, and day from the date value. Then you need to convert the extracted date value to text. Finally, you need to add the date value to the hyperlink.
To pass a dynamic date value to a parameter, complete the following:
1. From Crystal Reports, select the field you want to create a hyperlink on.
2. Right-click the field, choose 'Format Field'.
3. On the 'Format Editor', click the 'Hyperlink' tab.
4. Under 'Hyperlink type', click 'A website on the internet'.
5. Under 'Hyperlink information', click 'X+2'.
6. Type a formula similar to the following:
// Assign the date field to the variable date
DateVar MyDate := {DATE FIELD};
// Extract the Year, Month and Day and transform it to text.
StringVar MyYear := ToText(Year(MyDate),0,"");
StringVar MyMonth := ToText(Month(MyDate),0,"");
StringVar MyDay := ToText(Day(MyDate),0,"");
// Concatenate the year, month and day to the URL
"HTTP://<ServerName>/<VirtualDirectory>/<ReportName.rpt>?prompt0="+Date("+MyYear+","+MyMonth+","+MyDay+")"
NOTE: =====
Replace the (DateField) with your database date field and replace ServerName, VirtualDirectory, ReportName.rpt with their values.
For Example:
You want to pass the dynamic date value parameter through a hyperlink.
The Server Name is MyServer
The Virtual Directory is Finance/MyReports/
The Report Name is LastYearSales.rpt
The hyperlink text formula in the formula editor is:
// Assign the date field to the variable date
DateVar MyDate := {Start Date};
// Extract the Year, Month and Day and transform it to text.
StringVar MyYear := ToText(Year(MyDate),0,"");
StringVar MyMonth := ToText(Month(MyDate),0,"");
StringVar MyDay := ToText(Day(MyDate),0,"");
// Concatenate the year, month and day to the URL
""HTTP://MyServer/Finance/MyReports/LastYearSales.rpt?prompt0="+Date("+MyYear+","+MyMonth+","+MyDay+")"
Keywords
PASSING DATE VALUES HYPERLINKED REPORTS HYPERLINK PARAMETER PASS DATES URL Crystal Reports Hyperlinks and URLs Date Parameter , c2010246 , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To