Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

filling fields from a form label in crystal reports

Posted on 2004-09-02
14
Medium Priority
?
319 Views
Last Modified: 2010-04-24
i am new to using crystal reports in vb.net and am trying to make a simple report that display the text contained in label fields on a form i have. is there a way to do this? the data doesn't have to be from the DB. is there a way to say field = label.text
0
Comment
Question by:coletteck8
[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
  • 6
  • 5
  • 3
14 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967420
BTW, the best topic area for this question is:

http://www.experts-exchange.com/Databases/Crystal_Reports/

More expert Crystal people there.

Bob
0
 
LVL 7

Expert Comment

by:natloz
ID: 11967552
Set up Parameters on your report and the pass the parameter values to the report through code
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967566
Not to say that there aren't any here, though, just a higher probability of getting a quicker answer is all :)

Bob
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:coletteck8
ID: 11967622
i wasn't sure where to put the question, so thanks!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11967630
Yes, I understand, with so many topic areas, it is often a daunting task to decide :)

Bob
0
 

Author Comment

by:coletteck8
ID: 11968277
natloz,
i have the parameters setup on the report. still a bit confused however
if i have a form class that has label.text = class.applicant.name
and i want the report to show the name property from the label.text can you give me an example of how i would pass that to the report?
0
 
LVL 7

Expert Comment

by:natloz
ID: 11968492
0
 
LVL 7

Expert Comment

by:natloz
ID: 11968499
Sorry...that is C#....hold on.
0
 
LVL 7

Accepted Solution

by:
natloz earned 400 total points
ID: 11968551
   Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    '
    ' Load the selected report file.
    '
    Dim CR As New ReportDocument
    CR.Load(strReportPath)
    '
    ' Declare the parameter related objects.
    '
    Dim crParameterDiscreteValue As ParameterDiscreteValue
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldLocation As ParameterFieldDefinition
    Dim crParameterValues As ParameterValues
    '
    ' Get the report's parameters collection.
    '
    crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
    '
    ' Set the first parameter
    ' - Get the parameter, tell it to use the current values vs default value.
    ' - Tell it the parameter contains 1 discrete value vs multiple values.
    ' - Set the parameter's value.
    ' - Add it and apply it.
    ' - Repeat these statements for each parameter.
    '
    crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = strStartDate <------------------YOUR VALUE TO PASS
    crParameterValues.Add(crParameterDiscreteValue)
    crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
    '
    ' Set the Crytal Report Viewer control's source to the report document.
    '
    CrystalReportViewer.ReportSource = CR
0
 

Author Comment

by:coletteck8
ID: 11974683
will this still work if i am not using the report viewer? i only want to print the report, not view it at all.
0
 

Author Comment

by:coletteck8
ID: 11975110
i see the website where you obtained the above code, but it doesn't really help me. for instance, i'm not sure what each of the objects does and should this code be placed in my form class or in the report?
0
 
LVL 7

Expert Comment

by:natloz
ID: 11976157
This code would be placed in your forms code for example when a  button has been pushed.
You don't need to use the ReportViewer if you don't want to, parameters have nothing to do with the Viewer.
The important part is that you are passing the Parameters to the report before printing/viewing.

Do you know how to print a report using VB.NET code? If so, do something similar to what you see above up until the point of:

CrystalReportViewer.ReportSource = CR  <---Replace with your code for printing direct...passing CR as Report Source.
0
 

Author Comment

by:coletteck8
ID: 11976397
i'm getting invalid field name error beginning at this line
crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
0
 
LVL 7

Expert Comment

by:natloz
ID: 11976886
StartDate should be an actual Parameter name that you have defined in your Crystal Report...

Whatever your parameters names are, these should be used in place of "StartDate"

for example...If you have a parameter named "PersonsName" on your report...

and you had a field on your form called txtPersonsName...

 crParameterFieldLocation = crParameterFieldDefinitions.Item("PersonsName")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = txtPersonsName.text <------------------YOUR VALUE TO PASS
    crParameterValues.Add(crParameterDiscreteValue)
    crParameterFieldLocation.ApplyCurrentValues(crParameterValues)


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 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