?
Solved

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

Posted on 2010-01-12
16
Medium Priority
?
526 Views
Last Modified: 2013-11-26
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
Comment
Question by:concern_support
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
16 Comments
 
LVL 3

Accepted Solution

by:
infochandru earned 2000 total points
ID: 26300380
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
 

Author Comment

by:concern_support
ID: 26300434
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
 
LVL 3

Expert Comment

by:infochandru
ID: 26300485
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 

Author Comment

by:concern_support
ID: 26300943
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
 
LVL 3

Expert Comment

by:infochandru
ID: 26301031

ok good luck. try your best.
0
 

Author Comment

by:concern_support
ID: 26301115
so how to print? I am sure it is very easy.
0
 

Author Comment

by:concern_support
ID: 26301124
this is how i am doing in access, but i am new in crystal report.
=[forms]![TICKET]![startdate]
0
 
LVL 3

Expert Comment

by:infochandru
ID: 26301163

You just drag and drop the parameter field from field explorer.
0
 

Author Comment

by:concern_support
ID: 26301252
Dear Infochandru, Sorry, You didn't get my point.
0
 

Author Comment

by:concern_support
ID: 26301263
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
 
LVL 3

Expert Comment

by:infochandru
ID: 26301352
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
 
LVL 3

Expert Comment

by:infochandru
ID: 26301545
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 26302220
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
 
LVL 101

Expert Comment

by:mlmcc
ID: 26310635
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
 

Author Comment

by:concern_support
ID: 26310811
@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
 
LVL 35

Expert Comment

by:James0628
ID: 26320276
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question