×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

PLEASE HELP! Passing a date range to a report

PLEASE HELP! Passing a date range to a report

PLEASE HELP! Passing a date range to a report

(OP)
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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close