How to call a report from a form and set a default filter

del_toro02del_toro02 Member Posts: 19
I would like to call a report from a menu button of a form and I would like to have a default filter already set for the report (this default setting will depend on a data from the form).
any help on this one ?

Answers

  • kapamaroukapamarou Member Posts: 1,152
    For a fast solution look at the PrintRecords Function in table 112 (Sales Invoice Header)
  • del_toro02del_toro02 Member Posts: 19
    when I try to do something similar to the function printrecords in table 112, I get an error message saying that SETFILTER is an unknown variable.
  • del_toro02del_toro02 Member Posts: 19
    sorry, I found out what was wrong with my previous message but could you explain to me what is ReportSelection."Report ID" and SalesInvHeader in the formula hereunder :

    REPORT.RUNMODAL(ReportSelection."Report ID",ShowRequestForm,FALSE,SalesInvHeader);

    does it mean that the record SalesInvHeader will be set as default ?
  • del_toro02del_toro02 Member Posts: 19
    also be aware that the data I have in my form is not the same as the data item of the report.
    the data of my form and the data item of the report only have one field in common.

    let's say the data of my form is the country with country code as a key and country name. and the data item of my report is the customer with data such as name, address and country code.

    and the data I would like to set as default is the country code that I would take from the form.
  • SogSog Member Posts: 1,023
    edited 2008-12-16
    yes (the answer to the post above this and the previous post)

    The record you have as parameter must be in the report you try to run.
    So a local or global var of type record (customer) with a setrange on country should work.

    (some quick posting today apparently :) )
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • kapamaroukapamarou Member Posts: 1,152
    ReportSelection is something that doesn't interest you for this. But it is table 77 nad it contains a setup that states which report ID should be used based on the userID and the number Series used for posting the document.

    The SalesInvHeader is a variable of table 112 which contains the record you will print.

    IF before you call runmodal you do a SETRANGE on that record then you'll see the filter applied.
  • kapamaroukapamarou Member Posts: 1,152
    Assuming that: Rec = Country and Rec2 = Customer then:


    Rec2.SETRANGE(Country,Rec.Country);
    Report.RUNMODAL(ReportID,ShowRequestForm,FALSE,Rec2);
  • del_toro02del_toro02 Member Posts: 19
    works perfectly, thanks a lot
  • kapamaroukapamarou Member Posts: 1,152
    You're welcome. :D
  • SogSog Member Posts: 1,023
    Please set your topic to solved, it would be greatly appreciated
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
Sign In or Register to comment.