Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 11th, 2008, 02:16 PM
Registered User
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Binding Variables to Crystal Reports

I am using VS 2005 and the report viewer that comes along with this software...

I am developing an application and have declared and assigned values to variables. I've created my report and added the viewer to my form. When I execute the application everything is working the viewer sees my report and I am able to print.

I was wondering how I can use the values stored in my variables, and have them display in my report textboxes?

If there are any suggestions I'd appreciate the help thanks.

LNickol
GIS Assistant
Gwa' sala - Nakwaxda Nation
 
Old January 22nd, 2008, 07:09 AM
Authorized User
 
Join Date: Dec 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pannasn
Default

Hi,

Try the following procedure :

1. Create a formula field e.g., 'Field1' with with value "" i.e., empty quote.
2. Before loading the report, type the following line of code in the form code behind:

    reportName.DataDefinitions.FormulaFields["Field1"].Text=var;

3. Drag the formula field to the report and run the application.



I hope this will help u.


Thanks & Regards
Panna
 
Old January 22nd, 2008, 01:17 PM
Registered User
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I'll give it a try! Have a good Day


LNickol
GIS Assistant
Gwa' sala - Nakwaxda Nation
 
Old January 22nd, 2008, 03:17 PM
Registered User
 
Join Date: Jan 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok I've given that a shot so here I am...

Assume:
 - Form1 has textboxes
 - Form2 has accessed these textbox values and assigned them to variables.
 - The variables in Form2 are for test purposes assigned to label. When application is in running values for Form1 appear in the labels on Form2.
 - A report has been created and has a textbox field named txtFName
 - Report is named Employee_Profile.rpt
 - Form2 has a report viewer named CrystalReportViewer1

source code:

Public Class Form1
Inherits System.Windows.Forms.Form
Private SeeForm2 As New Form2(Me)

Private Sub cmdPrint_Click(ByVal sender...)Handles cmdPrint.Click
SeeForm2.Show()
End Sub

End Class

Public Class Form2
Inherits System.Windows.Forms.Form
Private callingForm as Form1

Public Sub New(ByVal newCallingForm as Form1)
MyBase.New()
InitializeComponent()
callingForm = newCallingForm
End Sub

Private Sub Form2_Load(ByVal sender As...)Handles MyBase.Load
Dim FName As String

FName = callingForm.txtFName.Text

'Testing purposes to see if values has been passed
'Me.lblFName.Text = FName

Employee_Profile1.DataDefinitions.FormulaFields{tx tFName as String} = FName

End Sub

End Class

Results from Build...

3 Errors

Error1 - Property access must assign to the property or use its value.
Error2 - Expression expected {
Error3 - Method arguements must be enclosed in paretheses.


I'm sure the solution is right in front of my face, I'm just having troubles seeing it right now! Any help on this source code or further explinations would be appreciated... Thanks so much to those that have taken the time to read this - and are able to offer solutions.








LNickol
GIS Assistant
Gwa' sala - Nakwaxda Nation
 
Old January 23rd, 2008, 04:27 AM
Authorized User
 
Join Date: Dec 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pannasn
Default

Hi,

If i m correctly getting ur code, u r using the textbox name as the index of FormulaFields in the following line :

Employee_Profile1.DataDefinitions.FormulaFields{tx tFName as String} = FName

Instead, Please write this :

Employee_Profile1.DataDefinitions.FormulaFields["Field1"] = FName

where Field1 is the formula field with empty string in the report.


Thanks
Panna





Similar Threads
Thread Thread Starter Forum Replies Last Post
comparision among crystal reports and Data reports avats Crystal Reports 0 April 13th, 2005 01:01 PM
How to create/design reports with crystal reports BassmaniaQ Crystal Reports 0 December 14th, 2004 04:58 AM
Crystal Reports Dynamic binding field objects velkropie Crystal Reports 0 December 1st, 2004 12:21 AM
Crystal Reports Dynamic binding field objects velkropie BOOK: Professional Crystal Reports for VS.NET 0 November 30th, 2004 11:35 PM
Binding reports iem BOOK: Professional Crystal Reports for VS.NET 3 November 5th, 2003 02:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.