Print Page | Close Window

pass variable in vb.net to crystal w/o using a DB?

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=5490
Printed Date: 29 Apr 2024 at 11:33pm


Topic: pass variable in vb.net to crystal w/o using a DB?
Posted By: nebchill26
Subject: pass variable in vb.net to crystal w/o using a DB?
Date Posted: 11 Feb 2009 at 7:26pm
does anyone know how i can pass a variable/parameter from visual basic.net without using a database?

an example is i like to pass a the value of a text box in vb.net to crystal report.



Replies:
Posted By: jkwrpc
Date Posted: 13 Feb 2009 at 12:59pm
You can create an empty formula and locate it on the report. Then you can pass the variable to the text property of the formula. I dont have a sample in front of me. I think the collection of formulas is found in the Report Document object model and is in Report Definitions. I could probably supply a sample later today if still needed.
 
I often use this in passing strings I generate from code to display on the report.
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net
 
 


Posted By: nebchill26
Date Posted: 15 Feb 2009 at 4:03pm
could you give me an example of this please?thanks


Posted By: jkwrpc
Date Posted: 17 Feb 2009 at 8:52am
Here is a sample from the CR .Net API reference. The idea is to create an empty formula box. Then use this method to pass in a value. You can reference the formula field by its name as a string and not its index value.  I do this when I have some dynamic value I create in code that is not in the database but need it to show on the report.
---------------
      Private Sub UpdateFormulas(ByVal myReportDocument As ReportDocument)
         myReportDocument.DataDefinition.FormulaFields.Item("myformula").Text = "{file.SALES} *.1"
         myReportDocument.DataDefinition.FormulaFields.Item(2).Text = "{file.SALES} + {file.COMMISSION}"
      End Sub
 ----------------
 
Hope this helps.
 
Regards,
 
John W.
http://www.CustomReportWriters.net - www.CustomReportWriters.net     



Print Page | Close Window