cancel
Showing results for 
Search instead for 
Did you mean: 

"Missing parameter values." Error when setting record selection formula

Former Member
0 Kudos

Setup - VS 2008, CR 2008 (v12.0), Win XP & C#.Net

I have a form which loops through all parameters (non-linked to sub reports, so only off the main report) and allows users to enter the values for each parameter. When hitting the preview button, I loop through all of the saved values, set the parameter field values and then add any additional filters into the recordselection formula as below. The problem i'm having is that the ReportDocument.HasRecords returns true if the ReportDocument.RecordSelectionFormula doesn't filter out every result.

For example, I have a list of customers and if I set the selection formula to filter out a specific customer, ReportDocument.HasRecors returns true, if I set the selection formula to filter something that doesn't exist i.e. customer "xk39df", the moment this line of code runs "ReportDocument.RecordSelectionFormula = rsFormula;" - ReportDocument.HasRecors returns the following exception as opposed to "False".

Message: Missing parameter values.

Source: CrystalDecisions.ReportAppServer.DataSetConversion

StackTrace: at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e)

at CrystalDecisions.CrystalReports.Engine.ReportDocument.hasRecords()

at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_HasRecords()

ErrorID: MissingParameterFieldCurrentValue

The strange thing is, it works fine if the recordselectionformula selects a record which exists in the results - all parameters have a current value except for the linked parameters.

This one has got me stumped!

 
foreach (ParameterFieldDefinition parameterField in ReportDocument.DataDefinition.ParameterFields)
            {
                var query = ReportObjects.Values.Cast<Filters>().Where(objects => objects.ParameterName == parameterField.Name.ToUpper().Trim());

                foreach (var item in query)
                {
                    parameterField.CurrentValues.Clear();
                    parameterField.CurrentValues.Add(item.ParameterValue);
                    parameterField.ApplyMinMaxValues(item.MinLength, item.MaxLengh);
                    parameterField.ApplyCurrentValues(parameterField.CurrentValues);
                }
            }

            var records = ReportObjects.Values.Cast<Filters>().Where(recordSelection => recordSelection.RecordSelectionFormula.Trim().Length != 0);

            foreach (var item in records)
                rsFormula += item.RecordSelectionFormula;

            if (rsFormula.EndsWith(" AND "))
                rsFormula = rsFormula.RTrim(5);

            ReportDocument.RecordSelectionFormula = rsFormula;

Accepted Solutions (1)

Accepted Solutions (1)

former_member203619
Contributor
0 Kudos

Hi Paul,

Try doing it through the report designer - maybe it will give you a better error message.

i.e

-load the report in the report designer

-modify the recordselection formula so that it is filtering a customer that doesn't exist

-Try to view the report.

Regards

Shawn

Answers (2)

Answers (2)

former_member203619
Contributor
0 Kudos

What order are you passing the following things in:

1. Dataset

2. Parameters

3. Recordselection Formula

4. Check for HasRecords

-Could you please try doing them in the order above - because it's possible that passing in the dataset can clear our parameters.

-Also - if you are doing any kind of filtering based on parameters / recordselection formula - it makes a lot more sense to do that at the dataset level - rather than at the report level.

Regards,

Shawn

Former Member
0 Kudos

Hi,

The report has it's own ADO Datasource set in crystal reports, so I just pass the log on information to the report object before doing anything else.


this.DataSourceConnections[0].SetConnection("ServerName", "Database", "sa", "Password");

I then do a refresh before applying the parameter values (I do this because the user can preview the report more than one time by using a preview button on the parameter form without re-loading the report object)


this.Refresh();

Then I set all parameter values followed by setting the recordselection formula.

Former Member
0 Kudos

Hi,

Sorry for late post, but was this ever resolved. I'm experiencing the same issue after loading my reports.

Former Member
0 Kudos

Hi Shawn, I just gave that a go and it seems to display the report just with no details section as expected.. no error messages at all?

Paul.