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

Crviewer in HTML tag

Status
Not open for further replies.

whitga

Programmer
Dec 12, 2002
3
US
I have two crystal reports that are showing at the same time in a web page. I would like to be able to show them side by side in a table format instead of on top of each other. How does htlm reference the crviewer as an object? I tried placing each object in each column of the table but it keeps commming up blank.

Here is the code I am running:


<!-- INVESTIGATION REPORT -->
<html>
<head>
<TITLE>Investigation Report</TITLE>
</head>
<BODY BGCOLOR=C6C6C6 LANGUAGE=VBScript topmargin=0 leftmargin=0>


<!--REVIEW PREVIEW SETTINGS FOR ACTX -->
'<table width = 100% ><tr><td width = 50%>

<OBJECT ID=&quot;CRViewer&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=50%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,5,0,217&quot;>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=0>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchExpertButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableSelectExpertButton&quot; VALUE=0>
</OBJECT>
</td>
<td>
<!--REVIEW PREVIEW SETTINGS FOR ACTX -->
<OBJECT ID=&quot;CRViewer1&quot;
CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
WIDTH=100% HEIGHT=99%
CODEBASE=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,5,0,217&quot;>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=0>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchExpertButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableSelectExpertButton&quot; VALUE=0>
</OBJECT>
</td></tr></table>


<!-- #include file=RetrieveIStore.csp -->
<%
'WRITTEN BY TIM MCGINNIS 11/15/02

'REPORTNAME IS THE NAME OF THE REPORT
'FUNCTION GetReportID Gets the Crystal Enterprise ID that represents this report
' and returns a Logon token.
'LOGONTOKEN IS TOKEN THAT CONTAINS THE LOGON INFO NEEDED TO LOGON TO CRYSTAL ENTERPRISE
'RECORDID Is the value for the Crystal Report Parameter
' You Could specify more than 1 parameter
'Each Parameter has the syntax param# = <value>
'Example param0=1&param1=Paul

' NOTES: When adding another report, you are responsible to
'This code is written only for the actx control
' 1) Set Title of report and review PARAM Settings for previewer
' 2) Build the parameter string and set in both places
' 3) Optionally, you may want to select a different viewer, or use the user default settings by not setting it at all'Use the active x Control viewer
'actx ActiveX
'nav_plugin Netscape Plug-in
'java Java using browser JVM
'java_plugin Java using Java Plug-in
'html_page Standard HTML
'html_frame DHTML with Frames
' 4) Supply the Subreport names and SQL Logon string


IF GetReportID(&quot;INV&quot;, RPTID, LOGONTOKEN) then
Dim URL

'URL without any parameters except connection
URL = &quot;/JCPRW/viewrpt.cwr?id=&quot; & RPTID & &quot;&apstoken=&quot; & LOGONTOKEN

'---------------Add param's here--------------------------------------------------------------------
'Add param's here
response.write &quot;<INPUT id=&quot;&quot;param0&quot;&quot; type=&quot;&quot;hidden&quot;&quot; value=&quot;&quot;&quot; & Request.querystring(&quot;param0&quot;) & &quot;&quot;&quot;>&quot;

'---------------Leave this line alone. Set params in VBScript--------------------------------------
response.write &quot;<INPUT id=&quot;&quot;txtURL&quot;&quot; type=&quot;&quot;hidden&quot;&quot; value=&quot;&quot;&quot; & URL & &quot;&quot;&quot;>&quot;
else
response.write &quot;<B> Could not find a report by that name. </B>&quot;
end if

IF GetReportID(&quot;PROP&quot;, RPTID, LOGONTOKEN) then
Dim URL1

'URL without any parameters except connection
URL1 = &quot;/JCPRW/viewrpt.cwr?id=&quot; & RPTID & &quot;&apstoken=&quot; & LOGONTOKEN

'---------------Add param's here--------------------------------------------------------------------
'Add param's here
response.write &quot;<INPUT id=&quot;&quot;param0&quot;&quot; type=&quot;&quot;hidden&quot;&quot; value=&quot;&quot;&quot; & Request.querystring(&quot;param0&quot;) & &quot;&quot;&quot;>&quot;

'---------------Leave this line alone. Set params in VBScript--------------------------------------
response.write &quot;<INPUT id=&quot;&quot;txtURL1&quot;&quot; type=&quot;&quot;hidden&quot;&quot; value=&quot;&quot;&quot; & URL1 & &quot;&quot;&quot;>&quot;
else
response.write &quot;<B> Could not find a report by that name. </B>&quot;
end if
%>

<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--

Sub window_onLoad()
Page_Initialize()
End Sub

Sub Page_Initialize
On Error Resume Next
Dim webBroker
Dim WebBroker1
Dim URL
Dim URL1

Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
Set webBroker1 = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
URL = txtURL.value
URL1 = txtURL1.value

if err.number <> 0 then
window.alert &quot;Unable to load Report Viewer to create it's resource objects.&quot;
else
Dim webSource0
Dim webSource1
Dim SQL_LOGONNAME
Dim SQL_PASSWORD

SQL_LOGONNAME = &quot;JC_CRUser&quot;
SQL_PASSWORD = &quot;52cr8737&quot;

Set webSource0 = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource0.ReportSource = webBroker
webSource0.URL = URL
webSource0.PromptOnRefresh = False

'----------Add Parameters------------------------------------------------------
'Set Parameters
webSource0.AddParameter &quot;promptex0&quot;, param0.value

'-----------Add login for main report-------------------------------------------
'Add User and Password for Main Report
webSource0.AddParameter &quot;USER0&quot;, SQL_LOGONNAME
webSource0.AddParameter &quot;password0&quot;, SQL_PASSWORD

'------------Add login for all sub reports with name----------------------------
'Add User and Password for Sub Report1
webSource0.AddParameter &quot;user0@cr_Offense_subbox5&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Offense_subbox5&quot; , SQL_PASSWORD

'Add User and Password for Sub Report2
webSource0.AddParameter &quot;user0@cr_weapon_subbox18&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_weapon_subbox18&quot; , SQL_PASSWORD

'Add User and Password for Sub Report3
webSource0.AddParameter &quot;user0@cr_vechile_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_vechile_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report4
webSource0.AddParameter &quot;user0@cr_teletype_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_teletype_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report5
webSource0.AddParameter &quot;user0@cr_evidence_bag_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_evidence_bag_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report6
webSource0.AddParameter &quot;user0@cr_Xref_subbox54&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Xref_subbox54&quot; , SQL_PASSWORD

'Add User and Password for Sub Report7
webSource0.AddParameter &quot;user0@cr_chemical_lab_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_chemical_lab_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report8
webSource0.AddParameter &quot;user0@cr_ballistic_lab_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_ballistic_lab_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report9
webSource0.AddParameter &quot;user0@cr_summons_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_summons_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report10
webSource0.AddParameter &quot;user0@cr_Arrested_sub&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Arrested_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report11
webSource0.AddParameter &quot;user0@cr_offense_subb&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_offense_subb&quot; , SQL_PASSWORD

'Add User and Password for Sub Report12
webSource0.AddParameter &quot;user0@cr_offense_subbox5a&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_offense_subbox5a&quot; , SQL_PASSWORD

'Add User and Password for Sub Report13
webSource0.AddParameter &quot;user0@cr_Crime_Incident&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Crime_Incident&quot; , SQL_PASSWORD

'Add User and Password for Sub Report14
webSource0.AddParameter &quot;user0@cr_weapon_subbox18a&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_weapon_subbox18a&quot; , SQL_PASSWORD

'Add User and Password for Sub Report15
webSource0.AddParameter &quot;user0@cr_vechile_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_vechile_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report16
webSource0.AddParameter &quot;user0@cr_teletype_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_teletype_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report17
webSource0.AddParameter &quot;user0@cr_evidence_bag_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_evidence_bag_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report18
webSource0.AddParameter &quot;user0@cr_Xref_subbox54a&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Xref_subbox54a&quot; , SQL_PASSWORD

'Add User and Password for Sub Report19
webSource0.AddParameter &quot;user0@cr_chemical_lab_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_chemical_lab_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report20
webSource0.AddParameter &quot;user0@cr_ballistic_lab_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_ballistic_lab_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report21
webSource0.AddParameter &quot;user0@cr_summons_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_summons_suba&quot; , SQL_PASSWORD

'Add User and Password for Sub Report22
webSource0.AddParameter &quot;user0@cr_Arrested_suba&quot; , SQL_LOGONNAME
webSource0.AddParameter &quot;password0@cr_Arrested_suba&quot; , SQL_PASSWORD

'----------------------Second Report Here-----------------------------------------------
Set webSource1 = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
webSource1.ReportSource = webBroker1
webSource1.URL = URL1
webSource1.PromptOnRefresh = False

'----------Add Parameters------------------------------------------------------
'Set Parameters
webSource1.AddParameter &quot;promptex1&quot;, param0.value

'-----------Add login for main report-------------------------------------------
'Add User and Password for Main Report
webSource1.AddParameter &quot;USER0&quot;, SQL_LOGONNAME
webSource1.AddParameter &quot;password0&quot;, SQL_PASSWORD

'------------Add login for all sub reports with name----------------------------
'Add User and Password for Sub Report1
webSource1.AddParameter &quot;user0@cr_Crime_Incident_sub&quot; , SQL_LOGONNAME
webSource1.AddParameter &quot;password0@cr_Crime_Incident_sub&quot; , SQL_PASSWORD

'Add User and Password for Sub Report2
webSource1.AddParameter &quot;user0@cr_Poperty_sub&quot; , SQL_LOGONNAME
webSource1.AddParameter &quot;password0@cr_Crime_Incident_sub&quot; , SQL_PASSWORD


'---------------------------------------------------------------------------
'Report Runs Now
CRViewer.ReportSource = webSource0
CRViewer.ViewReport
CRViewer1.ReportSource = webSource1
CRViewer1.ViewReport

end if

End Sub

-->
</SCRIPT>
</BODY>
</HTML>

 
Hey, I've never done this before until now... But I was able to get two reports to show up side by using a table. You have done the crviewer a lot different than what I have so I may be way off here... I did not notice in your code a mention of the rptserver.asp page. I know in the past, that If this was not there, the report would not run...

Just an idea...

mwa
 
The reports show up but they are one under the other. As soon as I place the objects inside a table my entire page goes gray. How did you get the reports inside the table? And get them to show up? :)
 
Below is my code. I basically used the seagate sample files to build this originally. It requires the rptserver.asp page to be included. Also, for simplicity, I used the same report twice. Here is my code:
Code:
<%@ LANGUAGE=&quot;VBSCRIPT&quot; %>
<%
Response.Buffer = False
%>
<HTML>
<HEAD>
<TITLE>Crystal Decisions ActiveX Viewer</TITLE>

</HEAD>
<BODY BGCOLOR=C6C6C6 ONUNLOAD=&quot;CallDestroy();&quot; onLoad=&quot;setTheTime();waitMessage();&quot; topmargin=0 leftmargin=0>
<div id=&quot;loadMessage&quot; style=&quot;border:1px solid #aaaaee;background-color:#ccccff;color:#666699;font-family:cursive;position:absolute;text-align:center;width:50%;padding:10px;top:200px;left:200px;&quot;> Please wait, loading...</div>
<br>
<%on error resume next

strOrg = request.form(&quot;org1&quot;)
reportname = &quot;pur1000.rpt&quot;
%>

<%'CREATE THE APPLICATION OBJECT                                                                     
If Not IsObject (session(&quot;oApp&quot;)) Then                              
  Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;CrystalRuntime.Application&quot;)
End If                                                               
                                                                     
' CREATE THE REPORT OBJECT                                     
Path = Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)                     
While (Right(Path, 1) <> &quot;\&quot; And Len(Path) <> 0)                      
iLen = Len(Path) - 1                                                  
Path = Left(Path, iLen)                                               
Wend                                                                  
                                                                      
'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

Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path & reportname, 1)

'Check for errors
If Err.Number <> 0 Then
  Response.Write &quot;Error Occurred creating Report Object: &quot; & Err.Description
  Set Session(&quot;oRpt&quot;) = nothing
  Set Session(&quot;oApp&quot;) = nothing
  Session.Abandon
  Response.End
End If

'More Crystal Settings
session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData

'Provide variables to hold your logon information 
UserId = &quot;USERID&quot;
Password = &quot;password&quot;

Set oMainReportTable = Session(&quot;oRpt&quot;).Database.Tables.Item(1)

'Provide the logon credentials
oMainReportTable.SetLogonInfo &quot;MYDSN&quot;, &quot;MYDB&quot;, CStr(UserId), CStr(Password)

'Set the values for the Stored Procedure's parameters
Session(&quot;oRpt&quot;).ParameterFields.GetItemByName(&quot;@p_ship_to_code&quot;).AddCurrentValue(strOrg)

'Retrieve the Records and Create the &quot;Page on Demand&quot; Engine Object
On Error Resume Next
session(&quot;oRpt&quot;).ReadRecords
'Check for errors
If Err.Number <> 0 Then                                               
  Response.Write &quot;Error Occurred Reading Records: &quot; & Err.Description
  Set Session(&quot;oRpt&quot;) = nothing
  Set Session(&quot;oApp&quot;) = nothing
  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
%>

<table width=100% height=100%>
<tr>
<td width=50%>
<OBJECT ID=&quot;CRViewer&quot;
	CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
	WIDTH=100% HEIGHT=85%
	 codebase=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,5,0,217&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>
</td>
<td width=50%>
<OBJECT ID=&quot;CRViewer2&quot;
	CLASSID=&quot;CLSID:C4847596-972C-11D0-9567-00A0C9273C2A&quot;
	WIDTH=100% HEIGHT=85%
	  codebase=&quot;/viewer/activeXViewer/activexviewer.cab#Version=8,5,0,217&quot;>
<PARAM NAME=&quot;EnableRefreshButton&quot; VALUE=0>
<PARAM NAME=&quot;EnableGroupTree&quot; VALUE=1>
<PARAM NAME=&quot;DisplayGroupTree&quot; VALUE=0>
<PARAM NAME=&quot;EnablePrintButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableExportButton&quot; VALUE=1>
<PARAM NAME=&quot;EnableDrillDown&quot; VALUE=1>
<PARAM NAME=&quot;EnableSearchControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableAnimationControl&quot; VALUE=1>
<PARAM NAME=&quot;EnableZoomControl&quot; VALUE=1>
</OBJECT>
</td>
</tr>
</table>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub Window_Onload
	On Error Resume Next
	Dim webBroker
	Set webBroker = CreateObject(&quot;WebReportBroker.WebReportBroker&quot;)
	if ScriptEngineMajorVersion < 2 then
		window.alert &quot;IE 3.02 users on NT4 need to get the latest version of VBScript or install IE 4.01 SP1. IE 3.02 users on Win95 need DCOM95 and latest version of VBScript, or install IE 4.01 SP1. These files are available at Microsoft's web site.&quot;
		CRViewer.ReportName = &quot;rptserver.asp&quot;
		CRViewer2.ReportName = &quot;rptserver.asp&quot;
	else
		Dim webSource
		Set webSource = CreateObject(&quot;WebReportSource.WebReportSource&quot;)
		webSource.ReportSource = webBroker
		webSource.URL = &quot;rptserver.asp&quot;
		webSource.PromptOnRefresh = True
		CRViewer.ReportSource = webSource
		CRViewer2.ReportSource = webSource
	end if
	CRViewer.ViewReport
	CRViewer2.ViewReport
End Sub


-->
</SCRIPT>

<script language=&quot;javascript&quot;>
function CallDestroy()
{
	window.open(&quot;Cleanup.asp&quot;,&quot;Cleanup&quot;,&quot;status=no,toolbar=no,location=no,menu=no,scrollbars=no,width=1,height=1&quot;);
        self.focus()
}
var firstTime, secondTime;

function waitMessage(){
    firstTime = <%=second(Now())%>;

    if(firstTime + 3 > secondTime){
        setTimeout(&quot;hideMessage();&quot;,(firstTime + 3 - secondTime)*1000 + 1);
        
      }
    else{
        hideMessage();
     }
}
function hideMessage(){
    document.getElementById('loadMessage').style.display='none';
}
</script>
<table>
	<tr>
		<td language=vbscript style='text-decoration: Underline; color: blue; Cursor: Hand' onclick=&quot;window.open 'default.asp','_self'&quot; >Choose Another Organization</td>
	</tr>
</table>

<script language=&quot;JavaScript&quot;>
<!--
    function setTheTime(){
        secondTime = <%=second(Now())%>;
    }
//-->
</script>
</BODY>
</HTML>

Hope that helps...
mwa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top