Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values from an web page to Crystal Reports

Status
Not open for further replies.

Cris

Programmer
Nov 29, 2000
16
0
0
ES
I'm passing From Date and To Date field to Crystal
Report. I want the From and To date values to printed in Page Header of the Report. ¿Is it possible?
Thanks ;-)


I'm using:
Version of Crystal Reports: 8
ODBC Connect
Programming: HTML, VBScript, ASP and the Web Component Server
 
How do you pass those date values, as parameters or within the records selection formula?
 
Within the records selection formula:
e.g.
&quot;...WHERE FD1>=CDate('10/02/2000') AND FD1<=CDate('10/05/2000')&quot;
 
Since you use WCS, do you pass the values with the URL?
Or you use CRAXDRT?
 
I don't use the URL to pass the parameters, instead I use an ASP page to pass them to the crystal report.
In that ASP I'm using something like this:

Set Session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(report_path, 1)
session(&quot;oRpt&quot;).RecordSelectionFormula = &quot;{table.FD1}>=CDate('10/02/2000') AND {table .FD1}<=CDate('10/05/2000')&quot;

And then I launch the report in the crviewer.
 
Got it, you use CRAXDRT.DLL.
First, does your selection formula work? I think, you have to convert the date values to the Crystal format, which is
Date(yyyy, mm, dd) so it would look like this:

session(&quot;oRpt&quot;).RecordSelectionFormula =
&quot;{table.FD1}>=Date(2000,10,02) AND {table.FD1}<=Date(2000,10,05)&quot;

You can try this as well:
session(&quot;oRpt&quot;).RecordSelectionFormula = &quot;{table.FD1} in Date(2000,10,02) to Date(2000,10,05)

Now, how to display those two dates in the report.
Create two formula fields inside the Designer, {@DateFrom) and {@DateTo}, place them whereever you want them to be and enter any date in them -
Date(2000,01,01) for instance, just to set the fields' data type.
Then, in your ASP page do the following, since you know values of these two variables:

sDateFrom = &quot;Date(2000, 10, 02)&quot;
sDateTo = &quot;Date(2000, 10, 05)&quot;

set Formulas = session(&quot;oRpt&quot;).FormulaFields
for i = 1 to Formulas.Count
if Formulas.Item(i).FormulaFieldName = &quot;DateFrom&quot; then
Formulas.Item(i).Text = sDateFrom
elseif Formulas.Item(i).FormulaFieldName = &quot;DateTo&quot; then
Formulas.Item(i).Text = sDateTo
end if
next

The dates you entered while creating the report will be overwritten with the new values.

This should do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top