Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Why can't Subreport display all detail? Post Reply Post New Topic
Author Message
Dean
Newbie
Newbie
Avatar

Joined: 01 Jun 2010
Location: Taiwan
Online Status: Offline
Posts: 14
Quote Dean Replybullet Topic: Why can't Subreport display all detail?
    Posted: 02 Jul 2010 at 3:51am

Hi, Expert
Why can't Subreport display all content?
I have a report, it has one mainreport and subreport,
they connect to the same DB(store procedure).
when I used VB code to show this report , mainreport can display well, but subreport
only display partial detail.

#####################################################################
::VB::
sub main()
Public oApp As New CRAXDRT.Application
Public oRpt As CRAXDRT.Report
Dim conn As New ADODB.Connection
Dim mainreport As New ADODB.command,subreport As New ADODB.command
conn.CursorLocation = adUseClient
conn.ConnectionString = "..."
conn.CommandTimeout = 1000
conn.Open

mainreport.ActiveConnection = conn
mainreport.CommandType = adCmdStoredProc
mainreport.CommandText = "Sp_text"
mainreport.CommandTimeout = 1000

mainreport.Parameters.Append command.CreateParameter("flag", adVarChar, adParamInput, 4, "I")
...

 Set mrpt = command.Execute
 
subreport.ActiveConnection = conn
subreport.CommandType = adCmdStoredProc
subreport.CommandText = "Sp_text"
subreport.CommandTimeout = 1000

...

 Set srpt1 = Command1.Execute
 
   Call SomRpt_Initial(App.Path & "\RPT\inv_rpt07T.rpt")
   oRpt.DiscardSavedData

   Call SOMRpt_AppendRecordset("Main;1", mrpt)
   Call SOMRpt_AppendSubReport("sub1", srpt1)
  


   CRViewer.ReportSource = oRpt
   CRViewer.ViewReport
   Exit Sub
  
end sub
  
Sub SOMRpt_AppendRecordset(tablename, p_rs)
    Dim Table1 As DatabaseTable
    Dim oRs As ADODB.Recordset
   
    Set oRs = p_rs
    Set Database = oRpt.Database
    Set Tables = Database.Tables
    Set Table1 = Tables.item(1)
    Table1.SetPrivateData 3, oRs
End Sub

Sub SOMRpt_AppendSubReport(Subrptname, p_rs)
    Dim Table1 As DatabaseTable
    Dim oRs As ADODB.Recordset
    Set subrpt1 = oRpt.OpenSubreport(CStr(Subrptname))
    Set oRs = p_rs
    Set Database = subrpt1.Database
    Set Tables = Database.Tables
    Set Table1 = Tables.item(1)
    MsgBox Table1.Name
    Table1.SetPrivateData 3, oRs
End Sub    
#####################################################################
::subreport::
[View(Design)]
Report Header
ps.There are three data on report
a. [ATTN: ][inv_rpt07;1.st_ct_name(string)]
b. [Tel : ][inv_rpt07;1.st_ct_tel(string)]
c. [Fax : ][inv_rpt07;1.st_ct_fax(string)]

[formula]
[ATTN: ].if trim({inv_rpt07;1.st_ct_name})="" then "" else "ATTN : "
[Tel : ].if trim({inv_rpt07;1.st_ct_tel})="" then "" else "Tel : "
...
#####################################################################

When I ran the process, mainreport can run well(display all data on report),
but subreport only display partial detail,
like "ATTN : " on the report.
It should be "ATTN: {inv_rpt07;1.st_ct_name}" ...

I think it can display "ATTN : "(although not ATTN: {inv_rpt07;1.st_ct_name} ) which mean
subreport has got the db data from vb, but why can't display all the content on report??

Have any Suggestion??

Thanks & Best Regards

Have a Nice Day!!
Best Regards.

Questions and Answers seem like same. All in your mind.

Larry Lai
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Jul 2010 at 3:39am
since I rarely use subreports, and I don't use code to set the stored proc  for subreports, much less the main report, I don't know if there is error there.
 
the questions that pop to mind first are:
1) is the schema in the report a match to what the stored proc is returning
2) how is the subreport linked to the main report
3) is there a value for the subreport...perhaps it is performing correctly, just not the way you expect.
 
HTH
IP IP Logged
Dean
Newbie
Newbie
Avatar

Joined: 01 Jun 2010
Location: Taiwan
Online Status: Offline
Posts: 14
Quote Dean Replybullet Posted: 06 Jul 2010 at 4:21am
I really appreciate your time lockwelle

I had found the answer.

I had searched for while on net, and saw a article
ref:http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_22900203.html

It mentioned about author set the same DB recordset's name on report(mainreport and subreport)
, So did I, then I went to change DB recordset's name of subreport(all must unique),
and it can completely run out result include subreport detail.

Is this the Answer of my question??
Have a Nice Day!!
Best Regards.

Questions and Answers seem like same. All in your mind.

Larry Lai
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.