List Form

bekiobekio Member Posts: 204
Hello everyone!

At from Employee List i want to display a field Number that i want to be increment from 1, for 1.
If i filter this form i want again that this field Number to be from 1 incremented by 1.

Need Help!

Answers

  • matttraxmatttrax Member Posts: 2,309
    I'm sure you can do it, but it's really going to slow down the form. What is the business need? Maybe there is a better solution.
  • KYDutchieKYDutchie Member Posts: 345
    Hi Bekio,

    It is possible and suprisingly easy to do, but it does involve quite a bit of processing.
    So I wouldn't do this if your employee table holds a lot of records.

    Declare 2 Global variables:
    1. TempInt, Integer : This will be your line number
    2. T5200, Record Table 5200.

    In the OnAfterGetRecord put the following Code:
    T5200.COPYFILTERS(Rec);
    IF T5200.FINDFIRST THEN
      IF T5200."No." = "No." THEN
        TempInt := 1
      ELSE
        TempInt := TempInt + 1;
    

    And then add the "TempInt" field to the table box as the first field.
    Make sure you set the "Editable" and "Focusable" properties to "No".

    Also set your caption to what it needs to be.

    Hope this helps,

    Regards,

    Willy
    Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.
  • vaprogvaprog Member Posts: 1,139
    This of course does not work because there's no guarantee it starts counting from the first record and moreover it increments its counter even on revisiting records shown already or jumping to new ones.
    What would work is the following code:
    T5200.COPYFILTERS(Rec);
    T5200.FILTERGROUP(10);
    T5200.SETFILTER(T5200."No.",'..%1',Rec."No.");
    T5200.FILTERGROUP(0);
    TempInt := T5200.COUNT;
    
    ... but that's a little expensive.

    I doubt, however, that this is what is really needed (I cant think of any useful application), but as matttrax said
    matttrax wrote:
    ... What is the business need? Maybe there is a better solution.
  • kapamaroukapamarou Member Posts: 1,152
    You need to use a second record on which you apply the same filters and the same sorting with the form. Then loop that recordset from the first record until you find a record with the same primary key as the one you are on on the form.

    This is something like MS Access (record x of y).

    BUT:

    a) Depending on the filters, sorting and number of records, it could be really slow.
    b) Once you do it, then the customer will start asking for the same thing on all forms.

    So think about it again and decide.

    I've done it for a customer but I really stressed out the negative side of the solution.
Sign In or Register to comment.