SmileyFace
Programmer
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) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
if session("debug"
= "Y" then
Response.Write "exec:Al Path=" & path & "<br>" & vbcrlf
end if
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt"
) then
Set session("oRpt"
= nothing
End if
On error resume next
if session("debug"
= "Y" then
Response.Write "Report=" & path & report & "<br>" & vbcrlf
end if
Set session("oRpt"
= session("oApp"
.OpenReport(path & report, 1)
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & err.number & Err.Description
Set Session("oRpt"
= nothing
Set Session("oApp"
= nothing
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
End If
session("oRpt"
.MorePrintEngineErrorMessages = False
session("oRpt"
.EnableParameterPrompting = False
session("oRpt"
.DiscardSavedData
ShipNum = Request.QueryString("custshp"
Datadateback = Date() - 5
DatadateCurr = Date()
if report = "ship5.rpt" then
SelectionFormula = "{t_ship5hdr.custshp}= '" & ShipNum & "'"
SelectionFormula = SelectionFormula & " AND {t_ship5dtl.shipent} >= '" & Datadateback & "'"
SelectionFormula = SelectionFormula & " AND {t_ship5dtl.shipent} <= '" & Datadatecurr & "'"
session("oRpt"
.RecordSelectionFormula = cstr(SelectionFormula)
end if
On Error Resume Next
session("oRpt"
.ReadRecords
if session("debug"
="Y" then
Response.Write "exec: MoreRequiredsteps.asp"
end if
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.number & Err.Description
Set Session("oRpt"
= nothing
Set Session("oApp"
= nothing
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine"
) Then
set session("oPageEngine"
= nothing
End If
set session("oPageEngine"
= session("oRpt"
.PageEngine
End If
Thanks a lot in advance!
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"
' CREATE THE APPLICATION OBJECT
On error resume next
If Not IsObject(session("oApp"
Set session("oApp"
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) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
if session("debug"
Response.Write "exec:Al Path=" & path & "<br>" & vbcrlf
end if
'OPEN THE REPORT (but destroy any previous one first)
If IsObject(session("oRpt"
Set session("oRpt"
End if
On error resume next
if session("debug"
Response.Write "Report=" & path & report & "<br>" & vbcrlf
end if
Set session("oRpt"
'This line uses the "PATH" and "reportname" variables to reference the Crystal
'Report file, and open it up for processing.
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & err.number & Err.Description
Set Session("oRpt"
Set Session("oApp"
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
End If
session("oRpt"
session("oRpt"
session("oRpt"
ShipNum = Request.QueryString("custshp"
Datadateback = Date() - 5
DatadateCurr = Date()
if report = "ship5.rpt" then
SelectionFormula = "{t_ship5hdr.custshp}= '" & ShipNum & "'"
SelectionFormula = SelectionFormula & " AND {t_ship5dtl.shipent} >= '" & Datadateback & "'"
SelectionFormula = SelectionFormula & " AND {t_ship5dtl.shipent} <= '" & Datadatecurr & "'"
session("oRpt"
end if
On Error Resume Next
session("oRpt"
if session("debug"
Response.Write "exec: MoreRequiredsteps.asp"
end if
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.number & Err.Description
Set Session("oRpt"
Set Session("oApp"
Response.write "<script language=JavaScript>"
Response.write "setTimeout(""window.close()"", 1500)"
Response.Write "</script> "
'Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine"
set session("oPageEngine"
End If
set session("oPageEngine"
End If
Thanks a lot in advance!