Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: VBNET 2008 Crystal Report 9 - Create New Row after Post Reply Post New Topic
Author Message
Lennie
Newbie
Newbie
Avatar

Joined: 14 Mar 2010
Location: New Zealand
Online Status: Offline
Posts: 17
Quote Lennie Replybullet Topic: VBNET 2008 Crystal Report 9 - Create New Row after
     Posted: 03 Apr 2010 at 3:10pm
Hi Good Guy Crystals, Clap
 
I need your help, I have being trying to solve it for the past 2 months. Having problem trying to create a new row after filling the TEXTOBJECT using DATAREADER.
 

Here is the explanation why using Crystal Report TEXTOBJECT. Instead of creating alot of Crystal Reports for transactions reporting, it's better to use TEXTOBJECTs ( Eg. txtData1, txtData2, txtData3, txtData4, txtData5, etc...)

 

With these txtData as TEXTOBJECT name it creates the Crystal Report very flexible. The various Progams that extraction different transactions from SQL SERVER use DATAREADER and fill the rows of records into txtDATA object.

 

I am hoping that some VB.NET Crystal Report Developer will share their knowledge of how to create a new row after fill the txtDATA object instead of override the txtDATA objects like its happening right now. Instead of displaying 7 rows of data it display only the last row as it overrides the row before it.

 

-----------------------------------------------------------------------------------

Private Sub btnShowReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowReport.Click

 

        Dim strSql As String = Nothing

 

        strSql &= "Select  OrderID,  OrderDate, ProductName" 

        strSql &= " From Invoices "

        strSql &= " Where CustomerId = '" & txtcustId.text & "' "

 

        sqlConn = New SqlConnection(connStr)

        sqlCmd = New SqlCommand(strSql, sqlConn)

        sqlConn.Open()

        sqlDR = sqlCmd.ExecuteReader

 

        ' ---- setup crystal Report option and TEXT Pbject defination ---- '

        Dim objRpt As New CrystalOrderInvoice

        Dim cryTextObject As TextObject = Nothing

        Dim FmulaNewLine As FormulaFieldDefinition = Nothing

 

        Dim cryFolder As String = "H:\GeneralCrystalReport\GenTrans.rpt"

 

        objRpt.Load(cryFolder)

        Me.CrystalReportViewer1.ReportSource = objRpt

        Me.CrystalReportViewer1.Visible = True

 

        While sqlDR.Read

 

            ' --- OrderID

            cryTextObject = objRpt.ReportDefinition.ReportObjects("ctxtOrderId")

            cryTextObject.Text = sqlDR("OrderID")

 

            ' --- OrderDate

            cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtOrderDate")

            cryTextObject.Text = sqlDR("OrderDate")

 

            ' --- productname

            cryTextObject = objRpt.ReportDefinition.ReportObjects("cTxtProduct")

            cryTextObject.Text = sqlDR("ProductName") 

 

          ' --- new line  

             FmulaNewLine = objRpt.DataDefinition.FormulaFields("FmulaNewLine")

            FmulaNewLine.Text = Chr(10) & Chr(13)   

 

     End While

 

       sqlconn.Close

 

    End Sub

 
 

Have a Good Day,

Cheers,
Lennie
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Apr 2010 at 9:44am
The simple answer is that you can't.  Crystal creates rows based on the rows in the data it connects to.  If you're setting the values in the text boxes at run time, then you can only set them once per time the report is run, hence you only have one row of data.
 
So, what you thought was a good, flexible way to create a report really isn't going to get you what you need.
 
-Dell
IP IP Logged
Lennie
Newbie
Newbie
Avatar

Joined: 14 Mar 2010
Location: New Zealand
Online Status: Offline
Posts: 17
Quote Lennie Replybullet Posted: 05 Apr 2010 at 11:54am
Hi hilfy
 
Thank you for your response.
 
Based on what you mentioned I am very curious. If Crystal Report technology is not that flexible then why does it have TEXT OBJECT ? Is it meant for Section Header only ?
 
My IT Development Manager had a read at your response 2 hours ago and she suggested to 6 of us to use ACCESS ReportWriter which is more flexible. Told her I am waiting for more responses from contributors.
 
Anyway, thanks for your response.
 
 
 
 
 

Have a Good Day,

Cheers,
Lennie
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Apr 2010 at 3:44am
Crystal is designed to read data from tables or SQL queries, it is not designed for you to programatically feed each row to it, although you could store the information in a DataTable and report off of that.
 
-Dell
IP IP Logged
Lennie
Newbie
Newbie
Avatar

Joined: 14 Mar 2010
Location: New Zealand
Online Status: Offline
Posts: 17
Quote Lennie Replybullet Posted: 07 Apr 2010 at 12:46am
Hi hilfy,
I am very puzzled by your response. I asked you whether Crystal Report Text Object is meant for Section Header only but you did not provide the answer to it.
 

Have a Good Day,

Cheers,
Lennie
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 07 Apr 2010 at 3:57am
No, text objects can be used anywhere and serve multiple purposes.  In addition to typing in text, you can drag fields into them to append fields together.
 
I've used them for column headings, in-line data labels, text for the body a letter, addresses by putting all of the fields of an address in one, etc.  You can set their values in the report definition or programmatically once per run of the report - you can't set their values programmatically multiple times within a single run of a report which it appears is what you're trying to do.
 
My response gave you an alternative method of producing your report - put the data you want to set for each row into rows in a DataTable object and use that DataTable as the table for your report.
 
-Dell
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