Hi Good Guys
I have using VBNET2008, Crystal Report 10, SQL SERVER 2000, NorthWind Database for testing purposes.
I have an interesting problem and need your help and suggestions.
It's how to create a NEW LINE at the end of filling the last TEXT OBJECT.
I have created CrystalReportInvoice.Rpt and embedded it onto VBNET2008 FORM via CrystalReportViewer. I was requested to use Crystal Report TEXT OBJECT for 3 columns of data to be filled by DATAREADER which consist of 7 rows of data.
The probem is only one Row was display instead of the 7 rows on the Crystal Report because the row override the one before it because no NEW LINE was created. I did not get it working with the coding (BLUE HIGHLIGHTED)
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
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
Please help me by listing step by step procedures to create a NEW LINE as I am new to Crystal Report..
Once I got it working, I will post the solution here to share with other Newbies who may have similar problems.