jacktripper
Programmer
Below is some code that I originally used to view a report in the browser with the Active X component. That worked fine.
Now I want to send it straight to the printer without viewing it. To do this, I just added the report.PrintOut function on the bottom (past all the error checking junk). However, nothing prints out.
What am I missing here? I don't get any error messages either....
Any help would be lovely.
-------------------------
<%@ LANGUAGE="VBSCRIPT" %>
<%
reportname = Request("reportName"
MasterID = Request("MasterID"
%>
<%
If Not IsObject (session("oApp") Then
Set session("oApp" = Server.CreateObject("CrystalRuntime.Application.9"
End If
Path = Request.ServerVariables("PATH_TRANSLATED"
While (Right(Path, 1) <> "\" And Len(Path) <> 0)
iLen = Len(Path) - 1
Path = Left(Path, iLen)
Wend
If IsObject(session("oRpt") then
Set session("oRpt" = nothing
End if
On error resume next
Set session("oRpt" = session("oApp".OpenReport(path & reportname, 1)
If Err.Number <> 0 Then
Response.Write "Error Occurred creating Report Object: " & Err.Description
Set Session("oRpt" = nothing
Set Session("oApp" = nothing
Session.Abandon
Response.End
End If
session("oRpt".MorePrintEngineErrorMessages = True
session("oRpt".EnableParameterPrompting = True
session("oRpt".DiscardSavedData
Session("oRpt".ParameterFields.GetItemByName("MyMasterID".AddCurrentValue(CStr(Request("MasterID"))
On Error Resume Next
session("oRpt".ReadRecords
If Err.Number <> 0 Then
Response.Write "Error Occurred Reading Records: " & Err.Description
Set Session("oRpt" = nothing
Set Session("oApp" = nothing
Session.Abandon
Response.End
Else
If IsObject(session("oPageEngine") Then
set session("oPageEngine" = nothing
End If
set session("oPageEngine" = session("oRpt".PageEngine
End If
'Sub PrintOut([promptUser], [numberOfCopy], [collated], [startPageN], [stopPageN])
'Member of CRAXDRT.Report
'Prints the report to printer.
Session("oRpt".printout false
%>
<html>
<head>
<title>Window open only for some time</title>
<script>
function closeCall()
{
window.close();
}
function autoCall()
{
setTimeout('closeCall()','1');
}
</script>
<body onLoad="autoCall();">
<p><B><H3>Your reports are now printing. Dance a jig. <BR> Click "Yes" to close this window and return to iDeal</p>
</body>
</html>