How to set FastReport3 query parameter in code

I have been testing FastReports3 and have everything working.  I have an ADOQuery adding INSIDE the report with a Parameter in the query string of :EnrollmentRID

I captured the OnBeforePrint and searched for the parameter.  I foundit and set it, but the report uses the default parameter that I added in design mode and ignores the parameter that I set.

Is there another place where I am supposed to do this?  or does anyone see something wrong with my code.

I go through all of the datasetas and check all of the parameters for each dataset against all of the possible parameters.

procedure TdmData.frxRptBeforePrint(Sender: TfrxReportComponent);
    sl          : TStringlist;
    ndx         : Integer;
    frxDS       : TFrxDataset;
    qry         : TADOQuery;
    ParamNdx    : Integer;
    ParamName   : String;

    //go through all of the queries and set the parameters -- check each query for
    //all possible parameters

    sl := TStringlist.Create;
        for ndx :=  0 to sl.count-1 do begin
            frxDS := frxRpt.GetDataset(sl[ndx]);

            qry := TADOQUery(TFrxDBDataset(frxDS).DataSet);
            for ParamNdx := 0 to qry.Parameters.Count-1 do begin
                ParamName := UPPERCASE(qry.Parameters.Items[ParamNdx].Name);

                if ParamName='PARTICIPANTRID' then
                    qry.Parameters.Items[ParamNdx].Value := fParticipantRID
                else if ParamName='ENROLLMENTRID' then
                    qry.Parameters.Items[ParamNdx].Value := fEnrollmentRID
                else if ParamName='VOUCHERRID' then
                    qry.Parameters.Items[ParamNdx].Value := fVOUCHERRID
                else if ParamName='SERVICERID' then
                    qry.Parameters.Items[ParamNdx].Value := fSERVICERID
                else if ParamName='FOLLOWUPRID' then
                    qry.Parameters.Items[ParamNdx].Value := fFOLLOWUPRID;


Kyle FosterCEOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

could it be, that the datasets are already open, before u set the parameters?
Kyle FosterCEOAuthor Commented:
I already checked that and active was set to false.

I found the solution myself.  Here it is if anyone is interested.

1--> Inside a FastReport3 .fr3 file you add a variable through the designer.  I added my sql parameter 'EnrollmentRID' and set it to 0.
2--> IN the TFrxADOQuery components Params editor I set the param value to <EnrollmentRID> which ties it to the variable defined in step 1 above.
3--> The fastreports TFrxReport component has an event 'ongetvalue' that is called once for each variable in the report prior to the report running the queries with parameters (Const VariableName:String;var Value:Variant).  So I simply checked the variable name and if it is 'EnrollmentRID' i set Value := fEnrollmentRID;
4-->  It Worked!

I have used Crystal Reports and Rave Reports extensively for years.  I was led to check out FastReports3 which is Delphi Based a couple of weeks ago through another question on Experts Exchange and as a Delphi Developer it is the MOST complete and flexible tool that I have seen.  Awsome!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
very interesting, didn't have FastReports3, but guess i should do a look to it

meikl ;-)
Kyle FosterCEOAuthor Commented:
thats fine
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

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.