Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Passing parameter to Crystal Reports

Posted on 2013-06-15
13
Medium Priority
?
411 Views
Last Modified: 2013-06-22
I gave up on using the built in report designer with VS 2010 and switched to Crystal Reports, it seems like are alot more posts and examples for CR.

I am passing a parameter that is an integer to my crystal report, I am using this parameter to filter my report. In my report i created a parameter as a number type, I have added the parameter value to the heading in my report just to see what the value is and to make sure its at least making it to the report.
My value being past from my form is 1240 for instance, however the value in my heading is 1240.00 which causes the filter to not match so no records are displayed.
I don't see anywhere in crystal reports to change the type of the parameter to integer, I see you can change the number type of a field on the report, but not in the parameter.

I also have this formula I dropped onto the details section of my report.
{Issues.IssueID} = {?IssueID1}

I have another report that I am passing a string parameter which is working fine, its just when I try to pass an int that I am having a problem.

Hopefully that made sense.

MW
0
Comment
Question by:WINN2012
[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
  • 2
13 Comments
 
LVL 10

Expert Comment

by:adriankohws
ID: 39250031
The easiest way is to treat it as a string and pass over, then you won't have problem.
And I am also curious, if you indeed pass an integer, how it became a decimal?
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39250117
WHen you create the parameter you should be able to set the type as a number.

Crystal only has a number type and the display is controlled by the formatting.

mlmcc
0
 

Author Comment

by:WINN2012
ID: 39250500
I tried changing the field to string in CR, that didn't work, it really has to do with the value when it gets into CR has a decimal, therefor when it does its search it cant find the record. Again, when passing strings its working fine, just with an int its not finding the record i want to print.
I am using the below code in my form.

Dim cryRpt As New ReportDocument
        cryRpt.Load("C:\Utility\Reports\IssueTrackerDetailReport.rpt")
 
        Dim crParameterFieldDefinitions As ParameterFieldDefinitions
        Dim crParameterFieldDefinition As ParameterFieldDefinition
        Dim crParameterValues As New ParameterValues
        Dim crParameterDiscreteValue As New ParameterDiscreteValue
 
        Dim user As String = ""
        Dim pwd As String = ""
        cryRpt.SetDatabaseLogon(user, pwd)
 
        crParameterDiscreteValue.Value = idToOpen1
        crParameterFieldDefinitions = _
        cryRpt.DataDefinition.ParameterFields
        crParameterFieldDefinition = _
        crParameterFieldDefinitions.Item("IssueID1")
        crParameterValues = crParameterFieldDefinition.CurrentValues
 
        crParameterValues.Clear()
        crParameterValues.Add(crParameterDiscreteValue)
        crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
 
        CrystalReportViewer1.ReportSource = cryRpt
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.

 
LVL 101

Expert Comment

by:mlmcc
ID: 39250517
As I stated, in Crystal there are only numbers 1234 is the same as 1234.0 when using a numeric comparison.

Can you uplod your rpt file?

mlmcc
0
 

Author Comment

by:WINN2012
ID: 39250561
Unfortunately I cannot access expert exchange on my work pc, so I have to tinker on it, then jump on my home pc.
 I did take a couple screen shots, that hopefully will help identify the problem, they are attached.
image001.png
image002.png
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39250686
What type is Issues.ID?

mlmcc
0
 

Author Comment

by:WINN2012
ID: 39250692
It is an integer.
Sure wish reports were as easy as msaccess reports.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39250709
Generally they are.

Try a VERIFY DATABASE.  

Are you getting any errors?
If so when?

mlmcc
0
 
LVL 10

Expert Comment

by:adriankohws
ID: 39251330
In your VB Code, you declare IssueID1 as integer?
0
 

Author Comment

by:WINN2012
ID: 39251712
Hi,
I've started over, just had to made to many changes, so..
I created a new report, for the datasource I selected a dataset from the "Project Data" list.
I just went through all the steps to create the report, adding the Issues table, then selecting ALL the field, which includes IssueID which is an integer.
I created a new form, added a Crystal Report Viewer, choose my report from the list.
Even with no parameters or formulas I dont get any data. If I refresh my report, it asks for my username and password. Strange thing is, The Server Name is IssueTrackerReportDetailsDataSet and the Database field is blank (grayed out). No matter what username and pw i use it dont work.
Now if i start over again but instead of choosing a dataset from "Project Data" and scroll down to "Create New Connection", then Microsoft OLE DB Provider for SQL Server, then Pick my Server, UserID, PW, and database and finally the table(s) I need, then drop them on the report. I can at least preview my data.

So I guess my question is, why can't I select my project datasources?

Please forgive me if I am being a knucklehead here, but I have just been beating myself up trying to understand how either the built in reports or crystal reports work.

I'm sure its something simple I am doing.

MW
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 39251824
Did you follow the instructions in the referenced article?

mlmcc
0
 

Accepted Solution

by:
WINN2012 earned 0 total points
ID: 39251864
This works, maybe I was over complicating it?

Dim cryRpt As New ReportDocument cryRpt.Load("C:\Utility\Reports\IssueTrackerDetailReport.rpt")
       
Dim user As String = ""
Dim pwd As String = ""
cryRpt.SetDatabaseLogon(user, pwd)

cryRpt.RecordSelectionFormula = "{Issues.ID} = " & idToOpen1
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh
0
 

Author Closing Comment

by:WINN2012
ID: 39267779
Code found in the internet seems to work for what I need.
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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

719 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