Create New Row after filling a row of TEXT OBJECT

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lenniekuah
    New Member
    • Oct 2006
    • 126

    Create New Row after filling a row of TEXT OBJECT

    Hi there,

    Using VBNET2008, Crystal Report 9, SQL SERVER 2000, Northwind database for application purposes.

    The CrystalReportIn voice.RPT was embedded onto VBNET2008 FORM via CrystalReportVi ewer1 whose datasource was not connected to table or dataset.

    As requested by Team Leader, 3 Crystal Report TEXT OBJECT were inserted in the Crystal Report SECTION DETAILS which are filled with data using DATA READER which consist of 7 rows of data but only one row was display because the DATAREADER Row override the row before it becaues no NEW LINE was created .

    Here are the coding

    Code:
     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
    [B]        Dim FmulaNewLine As FormulaFieldDefinition = Nothing[/B]
    
            Dim cryFolder As String = "H:\VBNet2008[LEFT][/LEFT]CrystalReportApps\CrystalOrderInvoice.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  
               [B]   FmulaNewLine = objRpt.DataDefinition.FormulaFields("FmulaNewLine")
                FmulaNewLine.Text = Chr(10) & Chr(13)  [/B] 
             
         End While
      
           sqlconn.Close
    
        End Sub
     
    
    
     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:\VBNet2008CrystalReportApps\CrystalOrderInvoice.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
    Last edited by lenniekuah; Mar 20 '10, 10:42 PM. Reason: TYPO ERROR
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    For as far as I can see, you refill the same objects over and over again in your loop.You should create the new objects within your While...End While-loop.

    Try

    Code:
    cryTextObject = New objRpt.ReportDefinition.ReportObjects("ctxtOrderId ")
    etc...

    Steven

    Comment

    • lenniekuah
      New Member
      • Oct 2006
      • 126

      #3
      Hi Awesome MrMancunian
      Thank you again for your information. I will try it out. Once I got it working I will post the coding here to share with Newbies who have the same approach.

      You are very awesome.

      Cheers,
      Lennie

      Comment

      • lenniekuah
        New Member
        • Oct 2006
        • 126

        #4
        Hi MrMancunian

        I amended the codes by adding the word NEW
        cryTextObject = New objRpt.ReportDe finition.Report Objects("ctxtOr derId ")
        cryTextObject = New objRpt.ReportDe finition.Report Objects("cTxtOr derDate")
        cryTextObject = New objRpt.ReportDe finition.Report Objects("cTxtPr oducte")

        It generated this error message to my surprise.

        Type 'objRpt.ReportD efinition.Repor tObjects' is not defined.
        Last edited by lenniekuah; Mar 23 '10, 10:59 PM. Reason: TYPO ERROR

        Comment

        • MrMancunian
          Recognized Expert Contributor
          • Jul 2008
          • 569

          #5
          Can you put up your complete solution for download? Then I can try it at my own PC :-)

          Steven

          Comment

          • lenniekuah
            New Member
            • Oct 2006
            • 126

            #6
            Hi MrMancunian,
            I have extracted all the coding and pasted on WORD Document. How to download it so that you have try it ? Do you mean paste the coding here as I have initially done it when I asked for help ?

            I don't see any Attachment Button opton here.


            Cheers,
            Lennie

            Comment

            • MrMancunian
              Recognized Expert Contributor
              • Jul 2008
              • 569

              #7
              Hi Lennie,

              Just ZIP your complete solution and put it up for download at rapidshare or something alike :-) Then send me the URL...

              Steven

              Comment

              • lenniekuah
                New Member
                • Oct 2006
                • 126

                #8
                Hi MrMancunian,
                I have no idea of any Internet Server where I can download my zip files

                Comment

                • MrMancunian
                  Recognized Expert Contributor
                  • Jul 2008
                  • 569

                  #9
                  Take a look at http://www.rapidshare.com/...

                  Steven

                  Comment

                  • lenniekuah
                    New Member
                    • Oct 2006
                    • 126

                    #10
                    Hi MrManCunian,

                    Thank you very much for your offer to help me. You are very awesome person.
                    I have download it as VbNet2008Crysta l.zip in the http://www.rapidshare.com/...

                    Here is the URL Link:

                    http://rs102tl.rapidshare.com/cgi-bi...04693242865787

                    Prior to download, I was testing almost similar application developed by another progammer and I encounter this error message from Crystal Report Viewer:- AxCrystalActive XReportViewer1


                    With Me.AxCrystalAct iveXReportViewe r1
                    .ReportSource = cryRpt <--- generate error "This value is Write-only "
                    .Refresh()
                    End With

                    Thank you for your help.

                    Have a Good Day,

                    Cheers,
                    Lennie

                    Comment

                    • lenniekuah
                      New Member
                      • Oct 2006
                      • 126

                      #11
                      Hi MrManCunian,
                      Lennie here,
                      How's my downloaded ZIP application regarding Crystal Report TEXT OBJECT ?
                      Can you please get back to me with information ?

                      Thanks

                      Comment

                      • MrMancunian
                        Recognized Expert Contributor
                        • Jul 2008
                        • 569

                        #12
                        Hi Lennie,

                        I've been away for a few days, so I wasn't able to respond. I will download your solution right away and get back to you soon :-)

                        Steven

                        Comment

                        • MrMancunian
                          Recognized Expert Contributor
                          • Jul 2008
                          • 569

                          #13
                          Lennie,

                          The link you posted is dead...Click it yourself and you'll see. Perhaps you posted the wrong link?

                          Steven

                          Comment

                          • lenniekuah
                            New Member
                            • Oct 2006
                            • 126

                            #14
                            Hi MrMancunian,

                            Good to meet you again. It's wonderful that you have a break.
                            I have uploaded the ZIP file again and the URL LINK is listed beow


                            1. Download Link: Click here to download file


                            MD5: F8FDE4F259734A4 682E18729D263BD 11

                            Comment

                            • MrMancunian
                              Recognized Expert Contributor
                              • Jul 2008
                              • 569

                              #15
                              Ok, can you hook me up with the following libs?

                              - AxCRVIEWER9Lib
                              - CRVIEWER9Lib

                              Steven

                              Comment

                              Working...