Home End User

Initializing Parameters

edited November 2010 in End User
Hi

RBEnt 11.08

I am wanting to initialize a parameter used in an autosearch. I have tried
both of the following but neither is working.


procedure ReportOnInitializeParameters(var aCancel: Boolean);
begin
Report.Parameters['ShiftDate'] := CurrentDate;
aCancel := false;
end;


procedure ReportBeforeAutoSearchDialogCreate;
begin
Report.AutoSearchCriteriaByName('Shift','ShiftDate').SearchExpression :=
DateToStr(currentdate);
end;


Any suggestions?

Regards

Tim Murfitt

Comments

  • edited November 2010
    Hi Tim,

    In my testing, using code identical to the code you have below in the
    OnInitializeParameters event, the autosearch value properly reflects the new
    parameter value assigned.

    Be sure you have the AutoSearchSettings of the parameter enabled and that
    you are linking the parameter to the autosearch field in DADE.


    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2010
    In RB 11, Report.Parameters['ParameterName'] is read-only. For RB 12, it was
    enhanced to be read/write. Try using
    Report.Parameters.Items['ParameterName'] to access the TppParameter object
    and set its Value property.

    myReport.Parameters.Items['ShiftDate'].Value := CurrentDate;

    Also keep in mind that you need to define the Report.Parameters[ ] in the
    report layout workspace and then bind the query to the parameter item.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited November 2010
    Nico

    I have checked and checked but can not get it to work correctly. I have gone
    back to a DBDemos data set and used just one string parameter as a test. I
    can see that the event is firing ok and i used ShowMessage in the event to
    try and display the value I had just set but it keeps coming back blank.

    I will email you the sample report i have used for testing.

    Tim

  • edited November 2010
    Nard

    Thanks for that. Now all sorted.

    Regards

    Tim

This discussion has been closed.