• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

how to print argument passed from VB.NET interface to Crystal report

Hi Experts,

Is there any way to show or print the argument passed from a VB.NET interface on crystal report.


Thanks.
Veh.bmp
0
concern_support
Asked:
concern_support
1 Solution
 
infochandruCommented:
Hope this will helps you,

Create crystal report with parameter fields.

then you set the value by,


ParameterFieldDefinitions pfDefs = doc.DataDefinition.ParameterFields;
ParameterFieldDefinition pfDef = pfDefs["ParameterName"];
ParameterValues pVal = pfDef.CurrentValues;
ParameterDiscreteValue pdVal = new ParameterDiscreteValue { Value = "12/31/2009" };
pVal.Add(pdVal);
pfDef.ApplyCurrentValues(pVal);


and in crystal report you can drag and drop parameter field as you want.
remember you must set all parameter fields value that are all created in crystal report design.
0
 
concern_supportAuthor Commented:
thanks, as shown in the screen shot. first of all i am passing my values to a query not to crystal report parameters. then that query is the data source for crystal report. my query and reports are working fine, but i want the passing dates to print on my crystal report. this is my first time, i am touching crystal report so please keep in mind the newer users.
0
 
infochandruCommented:
Have look at the following link, then you have some idea on parameter fields.

http://www.aspfree.com/c/a/ASP.NET/Working-with-Parameters-with-Crystal-Reports-and-ASP-NET-2-0/
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
concern_supportAuthor Commented:
the link is very helpful, however my design is a little bit change.
Actually i am using XML file as the Data source for my report and XML Data source is my query. now i can not adjust these instruction(instruction is URL) with my architecture, because i have worked more then 10 days on this architecture. just my boss want to print these dates on the crystal report.
0
 
infochandruCommented:

ok good luck. try your best.
0
 
concern_supportAuthor Commented:
so how to print? I am sure it is very easy.
0
 
concern_supportAuthor Commented:
this is how i am doing in access, but i am new in crystal report.
=[forms]![TICKET]![startdate]
0
 
infochandruCommented:

You just drag and drop the parameter field from field explorer.
0
 
concern_supportAuthor Commented:
Dear Infochandru, Sorry, You didn't get my point.
0
 
concern_supportAuthor Commented:
For your information my problem is not parameter. My problem is how to print the value passing from a Vb.net interface(not the ugly crystal report parameter dialogue) and print it on the report.
0
 
infochandruCommented:
Hi,
try the code on export button click,

ParameterFieldDefinitions pfDefs = doc.DataDefinition.ParameterFields;
ParameterFieldDefinition pfDef = pfDefs["ParameterName"];
ParameterValues pVal = pfDef.CurrentValues;
ParameterDiscreteValue pdVal = new ParameterDiscreteValue { Value = txtFromDate.Text };
pVal.Add(pdVal);
pfDef.ApplyCurrentValues(pVal);

here 'txtFromDate' is the field name that you want to show.
0
 
infochandruCommented:
The full code is here,

        Dim doc As ReportDocument
        Dim pfDefs As ParameterFieldDefinitions
        Dim pfDef As ParameterFieldDefinition
        Dim pVal As ParameterValues
        Dim pdVal As ParameterDiscreteValue

        doc = New ReportDocument()
        doc.Load("~\\path\\report.rpt")

        pfDefs = doc.DataDefinition.ParameterFields

        pfDef = pfDefs("ParameterName")
        pVal = pfDef.CurrentValues
        pdVal = New ParameterDiscreteValue()
        pdVal.Value = txtFromDate.Text
        pVal.Add(pdVal)
        pfDef.ApplyCurrentValues(pVal)
        doc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, True, "Report")
0
 
Éric MoreauSenior .Net ConsultantCommented:
check http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx and http://www.emoreau.com/Entries/Articles/2006/10/Crystal-Reports--Part-II.aspx

If you have a value in a parameter, you can place this parameter right on the report just like if it was a field from a database.
0
 
mlmccCommented:
Agree.  There are 2 methods of getting information to the report.
11.  Use parameters as stated above.  That is probably the easy method.

The other is to use formulas for those fields then through code change the formulas.  The changeis done very similarly to passing the parameter.

mlmcc
0
 
concern_supportAuthor Commented:
@mlmcc how to do it with formula? Can you write the syntax for me to get the parameter from another form as in the above screen shot?
0
 
James0628Commented:
If the parameters are actually being passed to some other query and not being passed through your report, then I don't think the report is going to have direct access to them.  I could be wrong.  I just run reports from CR, not from code like this, so maybe I'm missing something.

 If I'm correct, I only see a few basic options (although there certainly could be others):

 1)
 Create duplicate parameters in the report, remove the parameters from the query, and use the report parameters instead.  I understand that you may not want, or be able, to do that.  I'm just saying that, in general, that is one option.

 2)
 Create duplicate parameters in the report and pass the values to them _and_ to the query parameters.  The query would still be using the parameters as it does now.  The parameters in the report would simply be used to show the values on the report.

 3)
 Change the query to include the parameter values in the results.  Basically, just add a new column for each parameter.  Then the report could get the parameter values from those columns.  This kind of seems like the simplest solution to me, assuming that it's not a problem for you to add those columns to the query results.

 James
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now