Hi to all,
Have some problems with creating of report. For example, have 2 tables - "Employee" and "Pers"(have some key fields from Employee).
Data from those tables have to be shown in report, on pressing special button, that is on the form.
I can set filter in such a way
Employee.SETRANGE("No.",Rec."Pers");
REPORT.RUN(REPORT::"Test Report",TRUE,FALSE,Employee);
But I don't know how to set several filters, executed on 1 REPORT.RUN.
Tell me please, where I can read or find an example of what I need.
I'm still learning, thx for any help)
Comments
In SetFilter function remember to pass the parameter by value otherwise you'll have empty filters.
Moreover choose a non-internally used filtergroup in order to combine your filters with DataItemLink property and set them in OnPreDataItem trigger:
As I understand, I have to create function named "SetFilters", with record parameters "Employee" and "Pers". The code in it have to be
It will be activated on the onRun trigger with
Sorry if it's a stupid question, just want to make it all clear.
Not exactly, in the function you just need to copy the filters applied in the calling object from parameters record variables to global variables in the report:
Which you will have to use in OnPreDataItem trigger.
geordie taught you a more advanced technique to pass parameters to a report. If you just want to set filters for dataitems in the report programmatically, you neither need to meddle with FILTERGROUP nor need to create a function in the report to pass the parameters. Instead you can do like this: Done like this, the filters passed will be pre-populated in the request form, if you show it and the report is configured to accept user filter entries for the dataitem.
I find geordie's use of FILTERGROUP somewhat confusing. Setting the filter group to 10 before the function is called will later hide the filters from the user (something you did not ask for and thus might be misleading). Within the function, setting FILTERGROUP does not have any effect in this case, as COPYFILTERS copies filters from all filter groups to the same filter group in the destination respectively. So, use of FILTERGROUP is optional.
(SETTABLEVIEW, on the other hand, copies the filters from the current filter group only, but also sets the key, in the same way as would do.)
As I write before, I'm still learning and usage of different functions sometimes isn't enough clear for me. Yesterday was the first time I saw FILTERGROUP) So you're right, that is the reason,why I didn't ask and that is misleading. But I have already read about, for example even there: http://www.mibuso.com/howtoinfo.asp?FileID=22
I find your way more comfortable for me, cause for the time being I'm not an advanced developer but trying to become)
Thx for both of your answers.
Yes, my fault because I wrongly remember some problems using SETTABLEVIEW for more than one dataitem when running a report :oops: