Passing parameter to Crystal Reports

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
WINN2012Asked:
Who is Participating?
 
WINN2012Author Commented:
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
 
adriankohwsCommented:
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
 
mlmccCommented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
WINN2012Author Commented:
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
 
mlmccCommented:
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
 
WINN2012Author Commented:
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
 
mlmccCommented:
What type is Issues.ID?

mlmcc
0
 
WINN2012Author Commented:
It is an integer.
Sure wish reports were as easy as msaccess reports.
0
 
mlmccCommented:
Generally they are.

Try a VERIFY DATABASE.  

Are you getting any errors?
If so when?

mlmcc
0
 
adriankohwsCommented:
In your VB Code, you declare IssueID1 as integer?
0
 
WINN2012Author Commented:
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
 
mlmccCommented:
Did you follow the instructions in the referenced article?

mlmcc
0
 
WINN2012Author Commented:
Code found in the internet seems to work for what I need.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.