Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameters to Crystal Reports

Status
Not open for further replies.

RTorrance

Programmer
Apr 12, 2002
64
CA
Hello,
I am using VB .Net 2003 with Crystal Reports 8.5 and SQL Server 2000. I am trying to pass a datetime parameter to my report. The report seems to ignore the datatime parameter but no other parameter.
Any help would be appreciated.
Thanks
Rachael
 
Rachael,

Could you post the code that you are using to pass the value and how you are trying to get CR to accept it?

Is the datetime value in a textbox or is it a global variable?

Brian
 
Right now to test i'm just hardcoding the value in. Eventually I would like it to be either a dropdown list box or a datetime picker which would then be a variable of some sort.

The code i am using is:
Dim crReport As New ProductionReport2

Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition

Dim crParameterValues As ParameterValues
Dim crParameterStartDate As New ParameterDiscreteValue
Dim crParameterEndDate As New ParameterDiscreteValue
Dim crParameterPartNum As New ParameterDiscreteValue

'START DATE
crParameterStartDate.Value = CDate("4/1/2004 12:00:00 AM")

crParameterFieldDefinitions = crReport.DataDefinition.ParameterFields

crParameterFieldDefinition = crParameterFieldDefinitions.Item("Start Date")

crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)


Thanks for the reply.
Rachael
 
Rachael,

I can see what you are trying to do but do not know where the problem lies. I do have a suggestion though for something that you could try that should work.

Here is how I am passing in values to CR.

With in CR I use the formula generator to create a formula that has "" as its only code.

I then set up a global variable that can be read in the CRForm. Then within the CRForm the following code pulls that value of the global into the report.

'varaible to create the report document
Dim oDoc As ReportDocument

'transfer value of global to report
oDoc.DataDefinition.FormulaFields.Item("UserName").Text = "'" & userName & "'"

'view the report
CrystalReportViewer1.ReportSource = oDoc

I hope this helps,

Brian
 
Thank You very much for the reply. That might work for two of my parameters that are the datatime values. I do have another parameter that is string that can accept more than one value. Not sure if this will work for that one. Can I pass that parameter the other way and use your suggestion for the two dates? Not quite sure if that would work.

Rachael
 
Rachael,

I do not think there should be any problem even with your string variable. I have one item set up this way that passes through a long string ( up to 24 dates ). I think that as long as you are able to set it into a global variable it should work fine.

Brian
 
There have been a few issues with Crystal Reports and .Net. I've learned much from their site:

support.crystaldecisions.com

One such issue had something to do with the fact that if you created a report and initially had the "save data with report" option checked, and unchecked it later, then it wouldn't care. It recommended to resave the report under a new filename.

There are also many patches available for Crystal Reports which fix several issues. Give the website a try, and look at the patches, see if they can fix what you need. Beware though, some of the patches say something to the effect don't install until you read what they will do. I have never had a problem, however.
 
Thank You for all of the replys. I did get it to work using the method I was originally trying to use sometime ago. I have also read about some issues with CR and .NET, but none of the fixes seemed to be what I was looking for.
Anyway, it works now.
Thanks again.
Rachael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top