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!

Subreport on web 1

Status
Not open for further replies.

chioma

IS-IT--Management
Aug 10, 2001
34
IT
I publish my reports (CR 7.0) on web.
The reports doesn't function if contains a subreport (perhaps it is not supported on web.... I doesn't find documentation on this question on Seagate web site).
Of course the reports function in Client-server mode.
Is there someone that can help me?
 
I use the activex viewer too.
Are you use asp pages to launch report on web?
Thank you for your help.
 
Do you call your report through ASP using RDC or WCS?
 
Yes I am using asp pages to launch the report. I have a main report with header & footer subreports (so every report I do has a logo and such, and this way I don't have to put all that stuff in each one). Hope this helps,
Jessica
[ponytails2]
 
I use WCS ( but I don't know what is RDC), there is another particularity on my installation : I use the 8.00 viewer version ( but the others reports works perfectly ).

Thank you for your help.
 
Yes I pass a lot of parameters but pheraps I don't understand your first response, so I give you the interesting part of my asp:
Set ParamDefCollection = Session("oRpt").Parameterfields
set session("Param") = ParamDefCollection


'set session("Param") = Session("oRpt").Parameterfields

'''''''PARAMETER 1 (UTENTE)
set Param1 = session("Param").Item(1)
if not isnull(value1) then
ParamValue = Request.Form("ParamValue")
Call Param1.SetCurrentValue (CStr(ParamValue), 12)
else
Call Param1.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 2 (TIPO CLIENTE)
set Param2 = session("Param").Item(2)
if not isnull(value2) then
Call Param2.SetCurrentValue (CStr(value2), 12)
else
Call Param2.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 3 (SCELTA)
set Param3 = session("Param").Item(3)
if not isnull(value3) then
Call Param3.SetCurrentValue (CStr(Value3), 12)
else
Call Param3.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 4 (LINEA)
set Param4 = session("Param").Item(4)
if not isnull(value4) then
Call Param4.SetCurrentValue (CStr(Value4), 12)
else
Call Param4.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 5 (CODICE TPPRB)
set Param5 = session("Param").Item(5)
if not isnull(value5) then
Call Param5.SetCurrentValue (CStr(Value5), 12)
else
Call Param5.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 6 (FUORI PRODUZIONE)
set Param6 = session("Param").Item(6)
if not isnull(value6) then
Call Param6.SetCurrentValue (CStr(Value6), 12)
else
Call Param6.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 7 (SERIE)
set Param7 = session("Param").Item(7)
if not isnull(value7) then
Call Param7.SetCurrentValue (CStr(Value7), 12)
else
Call Param7.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 8 (FORMATO)
set Param8 = session("Param").Item(8)
if not isnull(value8) then
Call Param8.SetCurrentValue (CStr(Value8), 12)
else
Call Param8.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 9 (CODICE CLIENTE)
set Param9 = session("Param").Item(9)
if not isnull(value9) then
Call Param9.SetCurrentValue (CStr(Value9), 12)
else
Call Param9.SetCurrentValue (CStr("Tutti"), 12)
end if

'''''''PARAMETER 10 e 11 (INTERVALLO MESI)
set Param10 = session("Param").Item(10)
set Param11 = session("Param").Item(11)
if not isnull(mesev1) then
Call Param10.SetCurrentValue (CStr(mesev1), 12)
Call Param11.SetCurrentValue (CStr(mesev2), 12)
else
Call Param10.SetCurrentValue (CStr("-"), 12)
Call Param11.SetCurrentValue (CStr("-"), 12)
end if

'''''''PARAMETER 12 (LINGUA)
set Param12 = session("Param").Item(12)
if not isnull(lang) then
Call Param12.SetCurrentValue (CStr(lang), 12)
else
Call Param12.SetCurrentValue (CStr("it"), 12)
end if

'''''''PARAMETER 13 (TITOLO REPORT)
set Param13 = session("Param").Item(13)
if not isnull(lang) then
Call Param13.SetCurrentValue (CStr(reportitle), 12)
else
Call Param13.SetCurrentValue (CStr("Report"), 12)
end if

On Error Resume Next
session("oRpt").ReadRecords
If Err.Number <> 0 Then
Response.Write &quot;An Error has occured on the server in attempting to access the data source&quot;
response.write err.number & &quot; &quot; & err.description
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

''''''''''''''''''''''''''''''''V I E W E R
viewer = Request.Form(&quot;Viewer&quot;)
If cstr(viewer) = &quot;ActiveX&quot; then
%>
<!-- #include file=&quot;SmartViewerActiveX.asp&quot; -->
<%
ElseIf cstr(viewer) = &quot;Java using Browser JVM&quot; then
%>
<!-- #include file=&quot;SmartViewerJava.asp&quot; -->
<%
ElseIf cstr(viewer) = &quot;HTML Frame&quot; then
Response.Redirect(&quot;htmstart.asp&quot;)
Else
Response.Redirect(&quot;rptserver.asp&quot;)
End If

%>


Thank you very much
 
OK, you are using RDC (which is Report Designer Component), not WCS (Web Component Server). When you are saying that this report works fine in Client-server mode, does it mean that you're runing it from the Crystal Designer or some client-server application (i.e. VB)? Does the subreport report off the same database as the main one? I would first check the sequence of your parameters you are setting; if you try to set a value to a linking parameter (which is created by Crystal to link main report to a subreport), then it will not work. You can check on parameter name by adding this line to each of the blocks:
''''''PARAMETER 1 (UTENTE)
set Param1 = session(&quot;Param&quot;).Item(1)
' Add this line
Response.Write session(&quot;Param&quot;).Item(1).Name & &quot;<BR>&quot;
if not isnull(value1) then
ParamValue = Request.Form(&quot;ParamValue&quot;)
Call Param1.SetCurrentValue (CStr(ParamValue), 12)
else
Call Param1.SetCurrentValue (CStr(&quot;Tutti&quot;), 12)
end if

Also, opent the report in Crystal Designer and make sure that &quot;Save Data With Report&quot; is not checked, when you click on File menu item. A good test is to export the report from Cryatl Viewer to Crystal format, open it in the Crystal Designer and make sure all parameters were passed correctly.

Do you log the main and subreports on to the datasource (I don't see it your code, but it was probably skipped), using the SetLogoninfo methos?
 
The report works fine when I run it from the Crystal Designer , the main and the subreport works on the same database.
I use for database connection the setlogoninfo methods.
I have controlled all the parameters but I haven't found any linking parameters so I tried to run the report without linking parameters but it didn't function.
I can't export the report because the asp wait in a loop before starting the viewer in this instruction:
&quot;session(&quot;oRpt&quot;).readrecords&quot;.

Now I don't know what I can do , do you have any suggestion?

Thanks


 
hello everybody
i have a problem & i need help .
my main report contains 9 subreports , i activated the export button & i can save &export the main report via mapi but when i open the main report i found that subreports can't be opened .
firstly i made a text box & in it the command of export subreport & make its hyperlink on from file (subreport file )& in preview it opens the subreport but when mailing it subreport can't be opened.
so please help me as soon as possible .
thanks.
reham
rshaheenw@hotmail.com

 
Can you please insert these lines:

session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData

right above these two:

On Error Resume Next
session(&quot;oRpt&quot;).ReadRecords

If this doesn't work:
Just to make sure, the SetLogonInfo method is used for the subreport as well? You can test database connectivity while applying this method for both main and sub reports:

set CRDatabase = session(&quot;oRpt&quot;).Database
set CRTables = CRDatabase.Tables
for each CRTable in CRTables
CRTable.SetLogOnInfo &quot;servername&quot;, &quot;dbname&quot;, &quot;uid&quot;, &quot;pwd&quot;
' add this line - it will write true or false
Response.Write &quot;Testing main report<br>&quot;
Response.Write CRTable.TestConnectivity & &quot;<BR>&quot;
next

set CRSubreport = session(&quot;oRpt&quot;).OpenSubreport(&quot;sureportname&quot;)
set CRSubDatabase = CRSubreport.Database
set CRSubTables = CRSubDatabase.Tables
for each CRSubTable in CRSubTables
CRSubTable.SetLogOnInfo &quot;servername&quot;, &quot;dbname&quot;, &quot;uid&quot;, &quot;pwd&quot;
' add this line - it will write true or false
Response.Write &quot;Testing subreport<br>&quot;
Response.Write CRSubTable.TestConnectivity & &quot;<BR>&quot;
next

Make sure that TestConnectivity is &quot;true&quot;.



 
Thank you , I will try tomorrow (it's 22:30 and the server must shut down), then I send you my result.
 
You are great!!!
I have found the problem but I have not resolved it.
The problem are &quot;parametersFields&quot; in subreport, if I
remove them the report work.
I have tested database connectivity and it was O.K. for the report and for the subreport too.
Then I tried to insert these lines:

session(&quot;oRpt&quot;).MorePrintEngineErrorMessages = False
session(&quot;oRpt&quot;).EnableParameterPrompting = False
session(&quot;oRpt&quot;).DiscardSavedData

but for &quot;session(&quot;oRpt&quot;).EnableParameterPrompting = False&quot; the system gave me an &quot;internal server error&quot;, but if I remove this line I suppose that the report try to prompt the parameters in the subreport and go in a loop.

It's since saturday that i try to pass the parameters from the main report to the subreport but without result.

Is there a method to fix the parameters field in subreport?
for example like this(mainreport):
Set ParamDefCollection = Session(&quot;oRpt&quot;).Parameterfields
set session(&quot;Param&quot;) = ParamDefCollection


'set session(&quot;Param&quot;) = Session(&quot;oRpt&quot;).Parameterfields

'''''''PARAMETER 1 (UTENTE)
set Param1 = session(&quot;Param&quot;).Item(1)
if not isnull(value1) then
ParamValue = Request.Form(&quot;ParamValue&quot;)
Call Param1.SetCurrentValue (CStr(ParamValue), 12)
else
Call Param1.SetCurrentValue (CStr(&quot;Tutti&quot;), 12)
end if


Thank you very much for your help


 
Hi chioma,

Looks like you are on the right track. The point is that in Crystal Reports version 7 ASP applications, subreport parameters are seen as global to the main report so they are set as parameters of the main report. Here is how to test it:

Set ParamDefCollection = Session(&quot;oRpt&quot;).Parameterfields
set session(&quot;Param&quot;) = ParamDefCollection

for each Parm in session(&quot;Param&quot;)
Response.Write Parm.Name & &quot;<BR>&quot;
next

This will give you a list of all of the parameters (including those in subreport) in order so you can compare it to your code blocks and make sure you set the values to the right parameters.

Just keep in mind, that if you removed ALL parameters from the subreport, your report might not function propertly - if your subreport is linked to the main one. If you have to link the two, then Crystal will automaticaly create a &quot;linking&quot; parameter for you in the subreport; you can see that if you right-click on the subreport, select &quot;Change Subreport Links..&quot; option, then in the left bottom corner you'll see subreports' parameter bellow the &quot;Subreport Parameter Field to use:&quot; label. Also, if you've checked an option &quot;Select data in subreport based on field:&quot; and selected on of the main report fields, then that parameter will be automaticaly included into the subreports' record selection formula. This parameter works automaticaly for you and doesn't have to be set from within the code. Please let me know if I don't sound clear :).

What happens if you leave all your parameters in the report (both main and sub), but comment out the code, where you're passing them? Then if it the report works, uncomment block by block, until you get an error.

Or like you do it now, after removing parameters from the subreport and commenting out appropiate blocks of code, try adding parameters to the subreport one by one, until you get an error message.


 
Hi LV,
you are very clear in your explanation.
I tried all the things you wrote and others too.
The problem is that if I put a parameter field (ex:?Titolo) in the subreport the report doesn't work in &quot;web mode&quot; in any way.
The strange thing is that if I put a &quot;parameter field&quot; ((?Titolo) in the main report and in sub too and I run it with Crystal Designer the report works but it prompt the parameter two time in the windows &quot;Enter parameters value&quot;: one for main and one for sub( I listed with your istruction all the parameters and &quot;?titolo&quot; appeared only one time).
I need to pass the parameters to filter the data in subreport but if I try to use the parameters fields of the main (for example in selection formula) the designer say &quot;Unknow field&quot;. If I put a &quot;parameter field&quot; in the subreport with the same name the report doesn't works in &quot;web mode&quot; (I think because it try to prompt the value for the subreport!!).
I tried to pass the parameters trought the &quot;subreport links&quot; but in the Combo-box under &quot;Select data in subreport based on field:&quot; there weren't &quot;parameters fields&quot; but only report and database ones.
What do you thing ? Are this kind of behavior right for you?
I can try to put in the subreport all the &quot;parameter Fields&quot; with a different name (Ex:?Titolo for main and ?TitoloSUB for sub) pheraps the report run, but for me is a heavy solutions.

What do you think?

Bye and thanks a lot.
 
To see the &quot;linking&quot; parameter between the main and sub reports, you first need to select a field to link on. Right-click on the subreport, select &quot;Change subreport links&quot; option. In the &quot;Subreport Links&quot; dialog box, select a main report database field from the &quot;Available fields&quot; box in the upper left, then click the &quot;>&quot; button. The field you selected will be moved to the &quot;Field(s) to link to:&quot; box in the upper right. Once you do that, you'll see those &quot;Subreport Parameter field to use&quot; (with an automaticaly created parameter in it) and &quot;Select data in subreport based on filed:&quot; dropdowns appear at the bottom of the dialog box.
 
I'm sorry in the last post I have not explained the problem well(the language is an addition problem for me).
I have made all the operations you have described above, but when I dropdows &quot;Select data in subreport based on filed:&quot; I never found the &quot;parameters field&quot; that are present only in the subreport.

For example: I want to set the &quot;parameter field&quot; ?user_sub equal to ?user (field present in the main report and setted trough the asp page) so I make all the operations you have described above, but I don't find ?user_sub in the combo-box under the flag &quot;Select data in subreport based on filed:&quot;.

I need this kind of link because I need to pass data from the asp to subreport and the others ways to do this are failed as I described in the last post.

Do you have an idea?

Please let me know if I don't sound clear.

N.B.:I known I'm a disperate case: in Italy we say &quot;sono proprio sfigato&quot;

Bye

 
Hey, that's what the forums for, there is no disparate cases here. By the way, English is my second language too, I'm from Russia :).

If you created a parameter in the subreport, then you'll see it in the &quot;Subreport parameter field to use&quot; dropdown, not in the &quot;Select data in subreport based on filed:&quot; one. If I understood you correctly, you need to link main to sub by, for example, some user_id database field; you have a parameter ?user in the main report and you're setting a value to it through your ASP code. Your subreport should be filtered accordingly, by the same user_id. In this case, you don't need a parameter in the subreport, but you need to have the same user_id database field in it (which I guess, you do).

Back to our &quot;Subreport Links&quot; dialog: from the &quot;Available fields&quot; box, select your ?user parameter and move it to the &quot;Field(s) to link to:&quot; box. You'll see the two dropdowns and a checkbox appear at the bottom of the dialog. &quot;Subreport parameter field to use&quot; will display something like ?Pm-?user, which is your linking parameter. created by Crystal. Check the &quot;Select data in subreport based on..&quot; box and select user_id from it. Then if you go edit the subreport, you'll see this parameter participating in the subreport's record selection formula, something like {table.user_id}=?Pm-?user. You can repeat this for as many parameters as you want. Then, when you set values to parameters in the main report through the code, the main will interact with sub through those linking parameters.

Let me know if it makes sence.
 
Hi LV,
your last post was the right one : now the report works correctly.
The thing that I had not understood was that I must use the ?pm...(&quot;Subreport parameter field to use&quot; dropdown) parameters in subreports.(Last week I tried to set this parameters but if you are in &quot;&quot;Change Subreport Links..&quot; and you select a field, deflag &quot;Select data in subreport based on field:&quot; and then click OK, the parameter dissaper.
You must first click OK and then deflag.....)
I had another problem, because not all the parameters that I ask at the end-user trough asp are compiled so in the asp page I compose a Selection_formula only with the compiled parameters and then I pass it at the report with this instruction:
&quot;session(&quot;oRpt&quot;).RecordSelectionFormula = selection_formula&quot;

So I needed to set , with the same string, all the selection formula in subreport and I resolved it with this block of code:

'Loop through each section, one by one, checking for subreports
For i = 1 to sectionCnt
Set section = session(&quot;sections&quot;).Item(CInt(i))
Set sectionobjects = section.ReportObjects
Dim objectCnt
objectCnt = sectionobjects.Count

'When a subreport is found, display it's name above the smartviewer.
For e = 1 to objectCnt
If sectionobjects.Item(CInt(e)).Kind = 5 then
response.write (sectionobjects.Item(Cint(e)).Name )

dim Namesubreport
Namesubreport=sectionobjects.Item(Cint(e)).Name


set CRSubreport = session(&quot;oRpt&quot;).OpensubReport(Namesubreport)
selection_subreport= CRSubreport.RecordSelectionFormula & sql_and & selection_formula
CRSubreport.RecordSelectionFormula = selection_subreport


end if
Next

Next


Now I'm happy (I have some little problem with the &quot;performing grouping on server&quot; option but not at all and I will find to resolve it tomorrow).


Thanks for all and let me know if you need someone.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top