Jay Marz
Jay Marz

Reputation: 1912

Change Text Object Value of Crystal Report Dynamically in VB.net

I have this picture of my current format of crystal report. enter image description here

My problem is, I want to set the value of fullName field dynamically depending on the query result of my vb.net form. For example, I have this code from my vb form,

sql = "SELECT fullName FROM tblClient WHERE clientID = '" & ST-TAC-23 & "'"
da = new SqlDataAdapter (sql, con)
dt = new DataTable
da.fill(dt)

I want the dt value to be passed on fullName object in my crystal report. For example the dt value is Mark Zucker, I want the fullName field in my cr to display Mark Zucker also. How could possibly do that?

Upvotes: 0

Views: 12883

Answers (1)

Jay Marz
Jay Marz

Reputation: 1912

I have found out the best trick for this problem. This is how I fixed it.

In the load event of the form (form for crystal report viewer), I coded this lines,

Dim fName As TextObject
fName = rptDoc.ReportDefinition.ReportObjects("crFullName")
' display the value for the report
fName.Text = frmAccInventory.lblName.Text

Where "crFullName" is the name of the text object in crystal report. rptDoc is declared at frmAccInventory as new crystalReport1 (name of the crystal report file)

credits to Mikaykay of http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/daa7e60d-a444-449d-9ac2-a57415217bbc/

Upvotes: 2

Related Questions