Define ReqFilter: Date = Current accounting period

Hi all, I need to set the Date ReqFilter in a report to “current accounting period” (which is different from the calender month) as default that a user can change if needed. Can someone help me with this? Thanks. Tariq

Tariq, Do you have dates set anywhere in your system for accounting period ?? If not,you may need to speak to your NSC to have this added to your DB.

You can use a standard Navision function to do this for you. Create the following variables: ApplicationMgt, type CodeUnit, subtype ApplicationManagement DateText, type text, length 30 Add a textbox to the Request Form, with DateText as source. In the OnInit trigger of your report you put: DateText := ‘P’; ApplicationMgt.MakeDateFilter(DateText); This call to the CodeUnit will translate the “P” (for Period) into the start and enddates of the accounting period based on the workdate of the system. John

In addition: if you want to preset these dates in a Date(filter) field of the table, you don’t have touse a textbox, but do of course Table.DateFilterField := DateText; John

Just look at:# Codeunit 358 DateFilter-Calc Codeunit 359 PeriodFormManagement There lies all the answers you need! Examples where used PeriodFormManagement: in trendScapes forms by period Also look at the Customer Statistic form for Date-Filter Calc Date-Filter Calc Functions Include >>>> CreateFiscalYearFilter CreateAccountingPeriodFilter CreateAccountingDateFilter Use CreateAccountingPeriodFilter in your report Pass Variables for (DateFilter Text 30, DateName Text 30, WORKDATE, and a 0 for current Period); Then Just SETFILTER(“Date Filter”,DateFilter); CALCFIELDS(FlowField); Or for a set of record SETFILTER(“Posting Date”,DateFilter); And you have the Period name in DateName to disply on your form. Hmmmm! Landscape with 12 Periods to Compare How? To be really clever try Arrays StartDate:=CalcDate(’-1Y’,WorkDate); Create an array of say 12 Datefilter DateName and SalesLCY OnPreReport() For i := 1 to 12 Do CreateAccountingPeriodFilter(DateFilter[i],DateName[i],StartDate,i-1); OnAfterGetRecord() SETRANGE(“Date Filter”); // Clear the filter for i := 1 to 12 Do Begin SETFILTER(“Date Filter”,DateFilter[i]); CALCFIELDS(“Sales (LCY)”); SalesLCY[i]:=“Sales (LCY)” End; Now you have 12 Period “Sales (LCY)” values and 12 Period Names to show on your report. Easy this way and the result will be the same as your trendscapes! Note for any New Developers, look within the system to find a report or form that matches close to what you want to do, study the code, copy it and modify it to do what you want it to do. No need to re-invent the wheel if Navision has already Invented it, maybe it does not work quite the way you would expect, but it does work! Have Fun!! David Cox Edited by - David Cox on 2001 Sep 12 23:13:30

Thanks a lot guys for your replies. I need to try your suggested methods & will get back in case of sucess or failure. Thanks again. Regards, Tariq