Using Date Filter in Custom Form

upasanisandipupasanisandip Member Posts: 405
Hi,
I have created 1 form using table G/L Account (Chart of Accounts Overview).

Now This is customized form. I put From Date and To Date that user will enter. When user press Apply button created by me I want only those records to show. How can I do that .. Means which filter I have to use?

Any hints or suggessitoons welcome.

Thanks,
Sandip.

Comments

  • johnson_alonsojohnson_alonso Member Posts: 690
    Have you tried to use these coding as follows:

    IF fromdate <> 0D THEN
    SETFILTER("from date",'..%1',fromdate)
    ELSE
    SETRANGE("from date");

    IF ToDate <> 0D THEN
    SETFILTER("To Date",'..%1',ToDate)
    ELSE
    SETRANGE("To Date");

    Rgds,
    Johnson
  • upasanisandipupasanisandip Member Posts: 405
    Have you tried to use these coding as follows:

    IF fromdate <> 0D THEN
    SETFILTER("from date",'..%1',fromdate)
    ELSE
    SETRANGE("from date");

    IF ToDate <> 0D THEN
    SETFILTER("To Date",'..%1',ToDate)
    ELSE
    SETRANGE("To Date");

    Rgds,
    Johnson

    Ok Thanks johnson alonso
  • PoebblesPoebbles Member Posts: 35
    I think, you want to show only these GL Accounts with Amounts in the Date Range FromDate .. ToDate
    You can only use fields where the Datefilter FlowFilter has influence like e.g. "Net Change" (FlowField)
    You have to implement Code behind the Apply Button like
    Testing FromDate <> 0D
    Testing ToDate <> 0D

    setfilter(datefilter,'%1..%2',fromdate,toDate)
    Calculate the FlowField "Net Change" with repeat until loop and mark all records with "net change" <> 0
    after loop setfilter only to the marked records (markedonly)

    Regards
    Poebbles
  • mark_christsmark_christs Member Posts: 156
    Dear All,
    It's really interesting that there are two differents answers, which one is true depends on the owner of the question in this topic. He must select and try, but I am sure there is no perfect answer just by seeing not doing.
    I hope to know it soon, because I am also trying what upasandip is doing right now. If one of the answers are wrong, it doesn't mean the person who gave the answer doesn't understand.



    Rgds,
    Mark
  • upasanisandipupasanisandip Member Posts: 405
    Hi guys,
    My prob. solved by using the following line code.

    SETRANGE("Date Filter",FromDate1,ToDate1);
    FromDate1 & ToDate1 user will provide at runtime.

    The same given by Poebbles.

    Thanks.
  • David_CoxDavid_Cox Member Posts: 509
    Hi guys,
    My prob. solved by using the following line code.

    SETRANGE("Date Filter",FromDate1,ToDate1);
    FromDate1 & ToDate1 user will provide at runtime.

    The same given by Poebbles.

    Thanks.

    This is the correct solution, but be aware there are several fields that are affected by date filter:

    Balance = Not Affected by any date filters
    Balance at Date = Zero Date .. to Date
    Net Change = From Date .. To Date

    There is Credit Amount, Debit Amount and Budget Amount etc: as well.
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • johnson_alonsojohnson_alonso Member Posts: 690
    Hi guys,
    My prob. solved by using the following line code.

    SETRANGE("Date Filter",FromDate1,ToDate1);
    FromDate1 & ToDate1 user will provide at runtime.

    The same given by Poebbles.

    I think Poebbles doesn't write SETRANGE("Date Filter",FromDate1,ToDate1);
    but he/she writes :
    ...,
    Testing FromDate <> 0D
    Testing ToDate <> 0D
    setfilter(datefilter,'%1..%2',fromdate,toDate)...

    Just look at the red word, it's the different, nevertheless, you have done a good job then.



    Rgds,
    Johnson


    "Camino Palmero"
  • PoebblesPoebbles Member Posts: 35
    setfilter or setrange depends on the Software Engineer ...
    If you use setrange, you don't have to test the data before because the system sets filter like "..<ToDate>" or "<FromDate>.."
    If you use Setfilter the system sets filter with ' ' (empty Fields) and
    an error occurs..

    try it O:)

    By the way.... he :mrgreen:
  • themavethemave Member Posts: 1,058
    isn't this more complicated then it needs to be, the g/l account table has the field "date filter" already in it,

    put this field on your form and they can enter the date range there, doesn't require any coding to work
Sign In or Register to comment.