?
Solved

filling fields from a form label in crystal reports

Posted on 2004-09-02
14
Medium Priority
?
316 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

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