|
-
Oct 2nd, 2007, 09:35 AM
#1
Thread Starter
PowerPoster
Someone please give me an example of code for a crystal report with a subreport
I really need the above example using the designer in VB plz.
-
Oct 2nd, 2007, 10:26 AM
#2
Re: Someone please give me an example of code for a crystal report with a subreport
I think you will need to clarify your question. Code? Of all the subreports I have created not once did I need to code anything.
-
Oct 2nd, 2007, 10:40 AM
#3
PowerPoster
Re: Someone please give me an example of code for a crystal report with a subreport
I have Crystal reports with sub reports, but I don't use the designer in VB. I create them as stand alone reports and call them from the code.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Oct 2nd, 2007, 01:13 PM
#4
Re: Someone please give me an example of code for a crystal report with a subreport
-
Oct 3rd, 2007, 12:52 AM
#5
Thread Starter
PowerPoster
Re: Someone please give me an example of code for a crystal report with a subreport
Hi Guys,
I have the foolowing code in my vb app to generate my report:
Code:
Sub PopulateReport(Cid As Integer)
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim sql As String
Dim sql2 As String
Set con = GetConnection
lvwCompany.Enabled = False
Set oReport = New CrystalReport1 'oApp.OpenReport(App.Path & "\Reports\MyReport.rpt", 1)
sql = "select ci.ipkcompanyid,ci.companyname,ci.companyaddress,ci.cgroup,ci.area,ci.propertyowner," & _
"ci.callfrequency,ci.leaseexpires,ci.business,ci.followupdate,ci.comments,ca.calldate,ca.details,ca.ipkcallid,u.username as 'callby'" & _
" FROM " & _
"tblcalls ca,tblcompanyinfo ci,tblusers u " & _
"WHERE ca.ifkcompanyid = ci.ipkcompanyid " & _
"AND ca.callby = u.ipkuserid " & _
"AND ca.ifkcompanyid = " & Cid & " ORDER BY ca.calldate DESC;"
Set rs = con.Execute(sql)
sql2 = "SELECT ci.ipkcompanyid,co.ifkcompanyid,co.contname FROM " & _
"tblcontacts co,tblcompanyinfo ci WHERE co.ifkcompanyid = ci.ipkcompanyid " & _
"AND co.ifkcompanyid = " & Cid & ";"
Set rs2 = con.Execute(sql2)
With oReport
.Database.SetDataSource rs, , 1
.OpenSubreport("Contacts").Database.SetDataSource rs2, , 1
.PaperOrientation = 1
.PaperSize = 2
.EnableParameterPrompting = False
.DiscardSavedData
End With
Delay 2 'give report time to load
CrystalActiveXReportViewer1.ReportSource = oReport
CrystalActiveXReportViewer1.ViewReport
lvwCompany.Enabled = True
End Sub
In my designer for the report I have created a command for the main report and a command for the sub report:
Main Report Command:
Code:
select ci.ipkcompanyid,ci.companyname,ci.companyaddress,ci.cgroup,ci.area,ci.propertyowner,ci.callfrequency,ci.leaseexpires,ci.business,ci.followupdate,ci.comments,ca.calldate,ca.ipkcallid,u.username as 'callby',ca.details from tblcalls ca,tblcompanyinfo ci,tblusers u
where ca.ifkcompanyid = ci.ipkcompanyid
AND ca.callby = u.ipkuserid ORDER BY ca.calldate DESC
Sub Report Command:
Code:
SELECT ci.ipkcompanyid,co.ifkcompanyid,co.contname FROM tblcontacts co,tblcompanyinfo ci WHERE co.ifkcompanyid = ci.ipkcompanyid
Is this the wrong way of doing it. Please advise me. I am really stuck and I am new to CR XI.
One last thing guys, My main report works great but my SubReport displays nothing at all. I would really appreciate a fix to this problem.
Last edited by Nitesh; Oct 3rd, 2007 at 12:58 AM.
Reason: Addition of Informayion
-
Oct 3rd, 2007, 02:05 AM
#6
Thread Starter
PowerPoster
Re: Someone please give me an example of code for a crystal report with a subreport
someone please chack my subreport query. That is the problem. Because I hav created another subreport in which I just added the tables from which to use in the database expert, and I did not add a command and the subreport works fine. But I need to extract this info using a command.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|