Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write to DataReport

Status
Not open for further replies.

WaZda

Programmer
Jun 22, 2007
48
GB
Hi everybody and i wish u all a happy new year.
Am working on a project whereby i have to send some informations to a crystal report. Am using Visual Studio 2005. I would like to do some query to the SQL server then do some manipulations with the data and then send some of the data manipulated to report. I can do the query and the manipulation alright but i don't how to send the informations to the text box placed on my report.
Can someone please help?
Thank you.
 
Instead of using a textbox in your CR, create a parameter and put it in the same spot as your textbox. Then pass the data from your manipulation to the parameter.
 
It's an alternative. I know i could do it like this in vb6.
But in vb.net the code does work. To u know how to translate this in vb.net?

crystalReport.ParameterFields.GetItemByName("ParameterName").AddCurrentValue("ValueToPass")

WaZda
 
In other words, this is what am trying to do:
I have put a textbox on the report, now I want to create a parameter in the report then make the textbox in the report equal to the parameter value then sent the parameter value by code.
WaZda
 
Okay. Create your parameter. For argument sake, let's say it's a accepts integer values (1-4) which should correspond to 4 different labels ("Apple", "Orange", "Pear", "Pineapple"). We'll name the parameter "FruitOpt".

Next, create a Formula Field. We'll name it "Fruit".In the Forumla editor window, type the following: (Crystal Syntax)
Code:
Select FruitOpt
Case 0: "Apple"
Case 1: "Orange"
Case 2: "Pear"
Case 3: "Pineapple"

Now click and drag the "Fruit" formula field to your report in the same spot as the textbox.

When you set the parameter FruitOpt to 1 - 4 the Fruit field will automatically display the correct fruit.

Is this example what you were looking for?
 
Sorry, it should be "Select {?FruitOpt}" for proper Crystal Syntax.
 
Hi Qamgine,
Thank you very much for your help. i tried to understand your code but i just couldn't. and it is because i did make myself clear enough. So i'll try explaining better this time, here is the scenario:
I have 3 files: Form1, Form2 and CrytalReport1.rpt(which is the crystal report file)
form1: I will do the data manipulation in the form1 then finally send the information to the form2.
form2: i have a CrystalReportViewer to load the CrystalReport file (CrytalReport1.rpt). Informations should be received from form1 by codes and displayed in the various textbox, placed on the CrytalReport1.rpt .

I hope this one is much clearer. and once again, thank you for helping me.
WaZda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top