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!

Logging into Main Report with Subreports - 8.5

Status
Not open for further replies.

zwieback89

Programmer
Mar 8, 2001
42
US
Hi,

Using the examples of the ASPXMPS85.exe, I wrote the code to log into the report with the sub reports.

My main report has 7 sub-reports and all of them are linked to the main report. It is only in the main report that I have a parameter ?PatientID. I pass a parameter PatientID from the ASP page so that I can view the results only of that patient. But I am not able to see anything.

In CR 8.0, I just provided a recordselection formula and it worked.

How do I logon using the setLogonInfo method and also pass a parameter to the main report and also log on to the sub reports at the same time ? I am using CR 8.5 and IE 5.5

Hope to hear more on this.
Regards,
Padmaja.

My code is as follows:

-----------------------------------------------------------
<%
' This line creates a string variable called reportname that we will use to pass
' the Crystal Report filename (.rpt file) to the OpenReport method contained in
' the AlwaysRequiredSteps.asp.

reportname = &quot;Web_Kardex.rpt&quot;

' ALWAYS REQUIRED STEPS
' Include the file AlwaysRequiredSteps.asp which contains the code for steps:
' - create the application object
' - create the report object
' - open the report
%>
<!-- #include file=&quot;AlwaysRequiredSteps.asp&quot; -->
<%
'Request for variables.
stPatientID = Request.Form(&quot;PatientID&quot;)
%>
<!--#include file=&quot;Database/DBConnection.asp&quot; -->
<%
'Logon to the main report - Kardex.rpt
'set crtable = session(&quot;oRpt&quot;).Database.Tables.Item(1)
'crtable.SetLogonInfo &quot;Pubs Sample Database&quot;, &quot;pubs&quot;, cstr(userid), cstr(password)
'crtable.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(userid), cstr(password)

'Logon to the sub-reports using the SetlogonInfo method.
'Create a reference to the tables collection of the main report
Set mainReportTableCollection = Session(&quot;oRpt&quot;).Database.Tables

For Each Table in mainReportTableCollection
Table.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'Create reference to the subreport object by opening the subreport
'by using its name as specified in the report designer.

'1st subreport = web_Emergency_Contacts.rpt

Set subReportOne = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Emergency_Contacts&quot;)

Set subReportOneTablesCollection = subReportOne.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportOneTablesCollection
Table.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'-----------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'2nd subreport = web_allergies.rpt

Set subReportTwo = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_allergies&quot;)

Set subReportTwoTablesCollection = subReportTwo.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportTwoTablesCollection
subReportTwo.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'-------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'3rd subreport = web_Renal_Care_Teams.rpt

Set subReportThree = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Renal_Care_Teams&quot;)

Set subReportThreeTablesCollection = subReportThree.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportThreeTablesCollection
subReportThree.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'---------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'4th subreport = web_Renal_Access.rpt

Set subReportFour = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Renal_Care_Teams&quot;)

Set subReportFourTablesCollection = subReportFour.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportFourTablesCollection
subReportFour.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'----------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'5th subreport = web_HD_Orders.rpt

Set subReportFive = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_HD_Orders&quot;)

Set subReportFiveTablesCollection = subReportFive.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportFiveTablesCollection
subReportFive.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'----------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'6th subreport = web_Test_Orders.rpt

Set subReportSix = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Test_Orders&quot;)

Set subReportSixTablesCollection = subReportSix.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportSixTablesCollection
subReportSix.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'-----------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'7th subreport = web_Medication_Orders.rpt

Set subReportSeven = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Medication_Orders&quot;)

Set subReportSevenTablesCollection = subReportSeven.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportSevenTablesCollection
subReportSeven.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'-----------------------------------------------------------------------------------
'Create a reference to the subreport object by opening the subreport
'by using the name as specified in the report designer.

'8th subreport = web_Problem_List.rpt

Set subReportEight = session(&quot;oRpt&quot;).OpenSubReport(&quot;web_Problem_List&quot;)

Set subReportEightTablesCollection = subReportEight.Database.Tables

'Provide the logon credentials for the subreport
For Each Table in subReportEightTablesCollection
subReportEight.SetLogonInfo cstr(stODBC), cstr(stDatabase), cstr(stUserID), cstr(stPassword)
Next

'-----------------------------------------------------------------------------------
'The following section shows setting the Title ID.
'THe main report and the subreport should show the information for this Patient ID
'But the parameter ?PatientID exist only in the main report and not in the sub reports.
'All the reports are linked to the main report by means of the fields have a relationship
'with the field in the table of the main report.
Session(&quot;oRpt&quot;).ParameterFields.GetItemByName(&quot;PatientID&quot;).AddCurrentValue(Cdbl(stPatientID))


' MORE ALWAYS REQUIRED STEPS
' Include the file MoreRequiredSteps.asp which contains the code for the steps:
' - retreive the records
' - create the page engine
' - create the smart viewer and point it to rptserver.asp
%>
<!-- #include file=&quot;MoreRequiredSteps.asp&quot; -->
<%
' INSTANTIATE THE REPORT VIEWER
%>
<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top