Defualt value for a report filter?

pedroccdapedroccda Member Posts: 90
Is it possible to set a defualt value for a report filter? At the moment I filter using a date range calculated using code (first day of month-last day of month), but I want make possible for end user to change this range.
Kiki

Comments

  • WaldoWaldo Member Posts: 3,412
    I didn't test this code, but you should be able to do this by calling the report like this:
    recMyRecord.SETRANGE("Posting Date", datDateFilter);
    REPORT.RUNMODAL(intReportnumber,TRUE, TRUE, recMyRecord);
    

    Basically, you have to filter a record-variable, and call the report, when passing this record variable to the report.

    It's weekend now, and it's about 12:55 AM, and I'm working with Linux at the moment ... so I can't test or look up an example, but if this doesn't work ... just let me know, and I'll look it up on Monday ... :whistle:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • pedroccdapedroccda Member Posts: 90
    Waldo wrote:
    I didn't test this code, but you should be able to do this by calling the report like this:
    recMyRecord.SETRANGE("Posting Date", datDateFilter);
    REPORT.RUNMODAL(intReportnumber,TRUE, TRUE, recMyRecord);
    

    Basically, you have to filter a record-variable, and call the report, when passing this record variable to the report.

    It's weekend now, and it's about 12:55 AM, and I'm working with Linux at the moment ... so I can't test or look up an example, but if this doesn't work ... just let me know, and I'll look it up on Monday ... :whistle:

    I know this method...but I want to set a default value in the form that appear reporting field filter just before create a report... in this manner the user have yet a date range and if he want he can modify it.
    Kiki
  • WaldoWaldo Member Posts: 3,412
    You mean on the request form of the report?

    You could do this by creating a new function (eg, SetParameters) in the report, and calling this function before running the report (RUNMODAL), for exemple:
    repMyReport.SETPARAMETERS(datPostingDate);
    recMyReport.RUNMODAL;
    

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • pedroccdapedroccda Member Posts: 90
    Waldo wrote:
    You mean on the request form of the report?

    You could do this by creating a new function (eg, SetParameters) in the report, and calling this function before running the report (RUNMODAL), for exemple:
    repMyReport.SETPARAMETERS(datPostingDate);
    recMyReport.RUNMODAL;
    

    Ok, maybe I don't express my problem in a good way...
    My problem is how can I set a default value for a filter on the request form of the report that appear at report run?? I want that my calculated date range appear as proposal instead of the last data range inserted by user.
    Kiki
  • WaldoWaldo Member Posts: 3,412
    OnInitReport ... ?

    On the request form ... OnInit or OnOpenForm

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • colingbradleycolingbradley Member Posts: 162
    This works for running the Statement directly from the Customer Record via a menu:

    <Control1000000095> - OnPush()
    Cust.SETRANGE("No.","No.");
    Cust.SETFILTER("Date Filter",'..%1',WORKDATE);
    REPORT.RUN(REPORT::Statement,TRUE,FALSE,Cust);

    Hope this helps.
    Colin
    Experience is what you get when you hoped to get money
Sign In or Register to comment.