Accessing form columns

Duhast
Duhast Member Posts: 42
I want to avoid problems due to zup file loosing. When users loose zup file loose sorting of all tabular type forms.

I want to create a table like that :

User Form Field XPOS
USER1 Customer List No. 1
USER1 Cusomer List Phone No. 341
USER2 Customer List No. 1
USER2 Customer List Blocked 341

So, executing a codeunit at OnOpenForm trigger I must be able to sort all tabular type forms ignoring zup file loosing.

But, can I make that codeunit? Can I access to XPOS property of each column?

FOR i := 2 TO LastControlOfTabTypeForm DO BEGIN
FindPositionAtAboveTable;
CurrForm.Control(i).XPOS := table.XPOS;
END;


Is that possible ?

Sorry my English

Comments

  • kriki
    kriki Member, Moderator Posts: 9,132
    No it is not possible.
    Each control must be accessed by its name, not by a reference :(

    To sort the columns in a tablebox, the only way I found is to start with the column you want the most to the right and then the one just before and so on until the one you want most to the left.
    So, less or more like this:
    recPosition.RESET;
    recPosition.SETCURRENTKEY("User ID","Form ID",Position); // the higher the position, the more to the right
    recPosition.SETRANGE("User ID",USERID);
    recPosition.SETRANGE("Form ID",FORM::"The Form");
    recPosition.ASCENDING(FALSE);
    IF recPosition.FIND('-') THEN
      REPEAT
        CASE recPosition."Column ID" OF
          FIELDNAME("Field 1"): CurrForm.XPOS := 0;
          FIELDNAME("Field 2"): CurrForm.XPOS := 0;
          FIELDNAME("Field 3"): CurrForm.XPOS := 0;
          'Some Global Var Field': CurrForm.XPOS := 0;
        END;
      UNTIL recPosition.NEXT = 0;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Duhast
    Duhast Member Posts: 42
    Thanks kriki!!

    I'll try it!!