Refreshing FORM at fix interval

sunnyksunnyk Member Posts: 280
Hi guys,
I want o have a form based on Prod Order Line table which get refreshed after a predefined interval. Like, If I have 100 records in the Prod Order Line Table, than when i open this new form it will show the first 25 records, than after that interval it shows me next 25 records and keep goin unless i closes the form. Is it possible to refresh the data in a form.

Comments

  • garakgarak Member Posts: 3,263
    Is it possible to refresh the data in a form.

    Answer:
    Yes it's possible.
    Do you make it right, it works too!
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    sunnyk wrote:
    Like, If I have 100 records in the Prod Order Line Table, than when i open this new form it will show the first 25 records, than after that interval it shows me next 25 records...
    Do you mean if the interval is e.g. five seconds, when you open the form you will see the records 1-25, after five seconds you will see the records 26-50, after another five seconds you will see the records 51-75 and so on?
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • MalajloMalajlo Member Posts: 294
    Property of form: TImerInterval

    Code, trigger
    OnTimer()
    update(false)
    
  • sunnyksunnyk Member Posts: 280
    Thank you all. :D
  • sunnyksunnyk Member Posts: 280
    I wrote the Code like below in a function call REFRESHDATA() and calling this function from OnTimer.
    ProdOrderLine2.SETRANGE(ProdOrderLine2.Status,ProdOrderLine2.Status::Released);
    TotalOrders := ProdOrderLine2.COUNT;
    
    IF FirstTime THEN BEGIN
      IF ProdOrderLine.FIND('-') THEN BEGIN
        gvCount := 0;
    
        REPEAT
          TRANSFERFIELDS(ProdOrderLine);
          INSERT;
          gvCount += 1;
        UNTIL (ProdOrderLine.NEXT = 0) OR (gvCount = 0.25 * TotalOrders) ;
        FirstTime := FALSE;
      END;
    END ELSE BEGIN
      gvCount := 0;
      ProdOrderLine.NEXT(-1) ;------/Why?
      REPEAT
        TRANSFERFIELDS(ProdOrderLine);
        INSERT;
        gvCount += 1;
        FirstTime := FALSE;
      UNTIL (ProdOrderLine.NEXT = 0) OR (gvCount = 0.25 * TotalOrders);
    END;
    IF  ProdOrderLine.NEXT = 0 THEN
      FirstTime := TRUE;
    

    If i didnt use the line of code ProdOrderLine.NEXT(-1) it is skipping some records. Lets say i have 12 records, The first time it is showing the first 3 records then skip the fourth, than 5-7, skip 8th, thn 9-12 and skip 12th.

    And in the onTimer() i wrote
    DELETEALL;
    RefreshData;
    CurrForm.UPDATE(FALSE);
    
  • kapamaroukapamarou Member Posts: 1,152
    I personally avoid using timers, especially when they require COUNT or transactions. This would be my last option, only if there is no other way.
    sunnyk wrote:
    it is skipping some records

    This might be caused by
    UNTIL (ProdOrderLine.NEXT = 0) OR (gvCount = 0.25 * TotalOrders) ;
    

    because no matter what the result of
    (gvCount = 0.25 * TotalOrders)
    
    is the NEXT will be executed.
Sign In or Register to comment.