Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Profit Loss Statement Printing Post Reply Post New Topic
Author Message
kuldevbhasin
Newbie
Newbie
Avatar

Joined: 07 May 2008
Location: India
Online Status: Offline
Posts: 22
Quote kuldevbhasin Replybullet Topic: Profit Loss Statement Printing
     Posted: 19 Apr 2009 at 3:48am

hi

i know this is going to b very simple for u guys but i have really really eaten my head over this.

i have created 2 tables as under :
dTableDr
id                    Integer
Particulars      String
Amount           integer
 
similarly
dTableCr with the same fields
now what i want is that the contects of dTableDr and dTableCr should be displayed side by side.
like the following
 
Particulars                  Debit Amt       Particulars         Credit Amount
 
my prob. is
i created the report using both the tables
but if say dTableDr has 2 rows and dTableCr has 1 then the contents of dTableCr r displaying twice
 
i had created a left outer join between both the id which i had given as 1 for all
would love to know the solution
thankx in advance.
kuldev
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Apr 2009 at 6:17am
A left join will take all rows from the left table in the joing regardless of a matched join to the right table AND all rows from the right table that join to the left table.
If the data is the same on the first and second rows and you just want to suppress the duplication of information and you have a single record per dTableDr.ID just group on that and place all the items you want to display on the group header and suppress the detail rows altogther.
If this is not the case can you post some sample data to assist in a solution?
IP IP Logged
kuldevbhasin
Newbie
Newbie
Avatar

Joined: 07 May 2008
Location: India
Online Status: Offline
Posts: 22
Quote kuldevbhasin Replybullet Posted: 20 Apr 2009 at 7:39am
thankx for ur reply DBlank
i have added a seperate id for each and then its working fine but then the prob. is if there r 4 rows in the Credit table which is linked to the Debit table and the debit table is having 2 rows then only 2 rows from credit table too r displayed. hence i am adding blank rows to the debit table to get the total rows same in both dr. and cr. table.
 

Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

dTableDr = New DataTable("dTableDebit")

dTableCr = New DataTable("dTableCredit")

dTableDr.Columns.Add(New DataColumn("Id", GetType(Integer)))

dTableDr.Columns.Add(New DataColumn("Particulars", GetType(String)))

dTableDr.Columns.Add(New DataColumn("Amount", GetType(Integer)))

 

dTableCr.Columns.Add(New DataColumn("Id", GetType(Integer)))

dTableCr.Columns.Add(New DataColumn("Particulars", GetType(String)))

dTableCr.Columns.Add(New DataColumn("Amount", GetType(Integer)))

 

Dim iRowCount As Integer = dDebitTable.Rows.Count - 1

Dim i As Integer = 0

For i = 0 To iRowCount

Dim iRow As DataRow = dDebitTable.Rows(i)

Dim drNewRow As DataRow

drNewRow = dTableDr.NewRow

drNewRow.Item("Id") = 1

drNewRow.Item("Particulars") = iRow!Name

drNewRow.Item("Amount") = iRow!Amount

dTableDr.Rows.Add(drNewRow)

Next

iRowCount = dCreditTable.Rows.Count - 1

For i = 0 To iRowCount

Dim iRow As DataRow = dCreditTable.Rows(i)

Dim drNewRow As DataRow

drNewRow = dTableCr.NewRow

drNewRow.Item("Id") = 1

drNewRow.Item("Particulars") = iRow!Name

drNewRow.Item("Amount") = iRow!Amount

dTableCr.Rows.Add(drNewRow)

Next

Dim crForm As New FrmReportViewer

Dim mRpt As New rptTest

Dim mHead As String = "Income & Expense Statement A/c For The Period Ended :- " & XUptoDt.Date

Dim newDs As New DataSet("ds_FinalAccountDataSet")

newDs.Clear()

newDs.Tables.Add(dTableDr)

newDs.Tables.Add(dTableCr)

mRpt.SetDataSource(newDs)

mRpt.SetParameterValue("CoName", X_CoName)

mRpt.SetParameterValue("ReportHeading", mHead)

Dim CRViewer As New CrystalDecisions.Windows.Forms.CrystalReportViewer

crForm.CrystalReportViewer2.ReportSource = mRpt

crForm.Show()

End Sub

 
hope u dont have a laugh after seeing the code as i am very new to vb & crystal and hence have done it this way.
pls. guide.
 
thankx
 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 Apr 2009 at 11:11am

can you post some sample data of what is happening and what you need fixed in it?

IP IP Logged
kuldevbhasin
Newbie
Newbie
Avatar

Joined: 07 May 2008
Location: India
Online Status: Offline
Posts: 22
Quote kuldevbhasin Replybullet Posted: 21 Apr 2009 at 2:02am
it shows me 2 records on left i.e. debit side and 2 rec. on cr. side where as there r 4 recs. on the credit side. the above  code shows all 4 rec. on cr. side too but then i have to add 2 more records to the dr. side as blank. which is not right what i am doing.
though this is working for me right now but i know there would b some simple way to do it.
thankx
IP IP Logged
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