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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PLEASE HELP! Passing a date range to a report

Status
Not open for further replies.

SmileyFace

Programmer
Sep 10, 2002
99
US
I am having problems passing a date range to a report. Please help. I have to pass a shipnumber called custshp to the report along with the report name in this case ship5.rpt and a date range. When passing it I am getting the error message: Error Reading Records: A date-time is required here.

Now my report has a datefield and I need to pass a range. I have 2 questions:

1) In SQL server my dates are stored as mm/dd/yyyy and the report pulls out the date from a table in this database. Howver if I do 'Browse field data' on the field in the report it shows me the date like this mm/dd/yyyy 12:00:00AM. It has this same time attached to every date. Why is this happenning? Is this why I get that error?

2) Here is the code. Can someone tell me if I am passing the parameters the right way?

dim Report
Report = trim(lcase(Request.QueryString("ReportName"))) & ".rpt"

' CREATE THE APPLICATION OBJECT
On error resume next
If Not IsObject(session("oApp")) or session("oApp") is nothing Then
Set session("oApp") = Server.CreateObject("CrystalRuntime.Application")
End If ' CREATE THE REPORT OBJECT
'
'The Report object is created by calling the Application object's OpenReport method.

Path = Request.ServerVariables("PATH_TRANSLATED")
While (Right(Path, 1) <> &quot;\&quot; And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend

if session(&quot;debug&quot;) = &quot;Y&quot; then
Response.Write &quot;exec:Al Path=&quot; & path & &quot;<br>&quot; & vbcrlf
end if

'OPEN THE REPORT (but destroy any previous one first)

If IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if

On error resume next
if session(&quot;debug&quot;) = &quot;Y&quot; then
Response.Write &quot;Report=&quot; & path & report & &quot;<br>&quot; & vbcrlf
end if
Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & report, 1)
'This line uses the &quot;PATH&quot; and &quot;reportname&quot; variables to reference the Crystal
'Report file, and open it up for processing.

If Err.Number <> 0 Then
Response.Write &quot;Error Occurred creating Report Object: &quot; & err.number & Err.Description
Set Session(&quot;oRpt&quot;) = nothing
Set Session(&quot;oApp&quot;) = nothing
Response.write &quot;<script language=JavaScript>&quot;
Response.write &quot;setTimeout(&quot;&quot;window.close()&quot;&quot;, 1500)&quot;
Response.Write &quot;</script> &quot;
'Session.Abandon
Response.End
End If

session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData

ShipNum = Request.QueryString(&quot;custshp&quot;)
Datadateback = Date() - 5
DatadateCurr = Date()

if report = &quot;ship5.rpt&quot; then
SelectionFormula = &quot;{t_ship5hdr.custshp}= '&quot; & ShipNum & &quot;'&quot;
SelectionFormula = SelectionFormula & &quot; AND {t_ship5dtl.shipent} >= '&quot; & Datadateback & &quot;'&quot;
SelectionFormula = SelectionFormula & &quot; AND {t_ship5dtl.shipent} <= '&quot; & Datadatecurr & &quot;'&quot;
session(&quot;oRpt&quot;).RecordSelectionFormula = cstr(SelectionFormula)
end if

On Error Resume Next

session(&quot;oRpt&quot;).ReadRecords
if session(&quot;debug&quot;)=&quot;Y&quot; then
Response.Write &quot;exec: MoreRequiredsteps.asp&quot;
end if
If Err.Number <> 0 Then
Response.Write &quot;Error Occurred Reading Records: &quot; & Err.number & Err.Description
Set Session(&quot;oRpt&quot;) = nothing
Set Session(&quot;oApp&quot;) = nothing
Response.write &quot;<script language=JavaScript>&quot;
Response.write &quot;setTimeout(&quot;&quot;window.close()&quot;&quot;, 1500)&quot;
Response.Write &quot;</script> &quot;
'Session.Abandon
Response.End
Else
If IsObject(session(&quot;oPageEngine&quot;)) Then
set session(&quot;oPageEngine&quot;) = nothing
End If
set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
End If

Thanks a lot in advance!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top