Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Can I assign value to Parameters in code Post Reply Post New Topic
Author Message
peter
Groupie
Groupie


Joined: 08 Apr 2007
Location: United States
Online Status: Offline
Posts: 51
Quote peter Replybullet Topic: Can I assign value to Parameters in code
    Posted: 17 Apr 2007 at 3:22pm

Hi,

Can I assign a value to a Parameter in code so that I can hide the prompt  from user?
I tried to do it in formular like this:
{?pFacilityId} := 'SFO';
{?pFacilityId}
 
But CR 10 did not like it giving error.
 
I would be great if some one or Brian has a way to do it.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 18 Apr 2007 at 9:24am

Which object model are you using?  CrystalViewer or ReportDocument?  In either case, you have to access the Parameters property of the report.  It looks something like this:

ParameterDiscreteValue discreteVal = new ParameterDiscreteValue();
ParameterValues curvalues = new ParameterValues();
foreach (ParameterFieldDefinition parafld in crReport.DataDefinition.ParameterFields)
{
  if (parafld.DiscreteOrRangeKind.ToString() == "DiscreteValue")
  {
    discreteVal.Value = Request.QueryString[parafld.ParameterFieldName];
    if (discreteVal.Value != null)
    {
      curvalues.Add(discreteVal);
      parafld.ApplyCurrentValues(curvalues);
    }
  }
}
There are some other things you have to do if you have range value parameters.
 
-Dell
IP IP Logged
peter
Groupie
Groupie


Joined: 08 Apr 2007
Location: United States
Online Status: Offline
Posts: 51
Quote peter Replybullet Posted: 18 Apr 2007 at 1:41pm
Thank you for your response.
I'm not doing thru an application. I'm only writing the report using the CR designer.
I've tried all kinds but nothing works !!!
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 18 Apr 2007 at 1:51pm

You can't do it inside the report.

-Dell

IP IP Logged
peter
Groupie
Groupie


Joined: 08 Apr 2007
Location: United States
Online Status: Offline
Posts: 51
Quote peter Replybullet Posted: 18 Apr 2007 at 2:08pm
Thanks. YAH! I just tried diff way to get around with the requirement.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.