Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: Binding Variables to Crystal Reports Post Reply Post New Topic
Author Message
lnickol22
Newbie
Newbie
Avatar

Joined: 30 Jan 2008
Location: Canada
Online Status: Offline
Posts: 1
Quote lnickol22 Replybullet Topic: Binding Variables to Crystal Reports
    Posted: 30 Jan 2008 at 10:35am

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?

This is what I've got so far...

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{txtFName 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.


Liz Nickol
GIS Assistant
Gwa'-sala - 'Nakwaxda'xw Nation
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 30 Jan 2008 at 11:30am
The problem is that you are assigning raw text to a CR formula and it doesn't know what to do with it. It doesn't realize that you are assigning a string constant to it. Thus, you have to surround FName with quotes and pass this to CR. Then it will know that this is a string constant. I don't understand the "txtFName as String" part either. Is this your actual code? Anyway, here you go:

Employee_Profile1.DataDefinitions.FormulaFields["your formula name here"] = (char)39 + FName + (char)39;

Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.016 seconds.