How do I return field name/caption from a field number?

merrilmerril Member Posts: 38
Hi Guys,

Is there a way that I can use the field number to return the field name or caption of the associated field?

Thanks in advance

Answers

  • kapamaroukapamarou Member Posts: 1,152
    Take a look at the contents of the Field Table (Create a list form based on it...)
  • merrilmerril Member Posts: 38
    kapamarou wrote:
    Take a look at the contents of the Field Table (Create a list form based on it...)

    Whats the full name of this table. Cant seem to find it in the table listing?
  • MBergerMBerger Member Posts: 413
    Another possibility is using Record- en Fieldrefs.
  • TomasTomas Member Posts: 420
    merril wrote:
    Hi Guys,

    Is there a way that I can use the field number to return the field name or caption of the associated field?

    Thanks in advance

    If you are talking about table fields(No./Name/Description/etc), then you could create a variable for table "Field". Then, it would be just a matter of filtering.
  • kapamaroukapamarou Member Posts: 1,152
    It's table number 2000000041 name Field.
  • merrilmerril Member Posts: 38
    kapamarou wrote:
    It's table number 2000000041 name Field.

    I dont have that told on the sytem I'm working on
  • merrilmerril Member Posts: 38
    I'm getting the field number form the change log and the table from the change log. I want to uses these two values to give me the name or caption for that field
  • kapamaroukapamarou Member Posts: 1,152
    What version do you use???

    You won't find that table under the object designer. You need to create a new form using the wizard, lookup the tables and select it (Or type it directly). Run the form to investigate the structure of the table and the you can declare a Rec variable based on that table and use it.
  • DenSterDenSter Member Posts: 8,305
    merril wrote:
    kapamarou wrote:
    It's table number 2000000041 name Field.

    I dont have that told on the sytem I'm working on
    The Field table is a virtual table. You won't find it in the table list in the object designer, but it can be selected as the source table for a form or the subtype of a record variable.
  • merrilmerril Member Posts: 38
    kapamarou wrote:
    It's table number 2000000041 name Field.

    Ok. I have used this table but when I try and filter on it I dont get data. If I hard code the tableno as follows:
    rFields.SETFILTER(TableNo,'%1',18);
    

    then I get data. But if I do it like this I dont get anything.
    rFields.SETFILTER(TableNo,'%1',rChangeLogEntry."Table No.");
    

    Any suggestions
  • kapamaroukapamarou Member Posts: 1,152
    You'll need to post here your code so we can help...
  • merrilmerril Member Posts: 38
    I have a code unit bases on the change log. For every record in the change log I need to get the field name in that record. I only have the table no and field no. So I uses this to lookup the name in the Fields table
        rFields.SETFILTER(TableNo,'%1',rChangeLogEntry."Table No.");
        rFields.SETFILTER(FieldName,'%1',rChangeLogEntry."Field No.");
    
        IF rFields.FINDFIRST THEN
          vFieldName :=  rFields.FieldName;
    
  • kapamaroukapamarou Member Posts: 1,152
    Is this part of your code? I don't see here a loop or a starting point for the rChangeLogEntry table.

    I would expect :
    IF rChangeLogEntry,FIND('-') THEN REPEAT 
    .
    .Your code here..
    .
    .
    UNTIL rChangeLogEntry.NEXT = 0;
    

    However, if you have a loop for it or pass it as a parameter then I would add a breakpoint in your code to see the values of rChangeLogEntry in order to follow the filters applied in th feilds table...
  • merrilmerril Member Posts: 38
    this is part of my code that is in the
    Change Log Entry - OnBeforeExitRecord()
    

    so the data port loops through the Change log for entry written between a certain datatime stamp
  • kapamaroukapamarou Member Posts: 1,152
    If your data item is called Change Log Entry and you are in OnBeforeExport??? try the following:
        rFields.SETFILTER(TableNo,'%1',"Table No.");
        rFields.SETFILTER(FieldName,'%1',"Field No.");
    
        IF rFields.FINDFIRST THEN
          vFieldName :=  rFields.FieldName;
    
    

    OR
        rFields.SETFILTER(TableNo,'%1',"Change Log Entry"."Table No.");
        rFields.SETFILTER(FieldName,'%1',"Change Log Entry"."Field No.");
    
        IF rFields.FINDFIRST THEN
          vFieldName :=  rFields.FieldName;
    
    

    Most probably it's because rChangeLogEntry is initialized and doesn't follow the dataport record.
  • merrilmerril Member Posts: 38
    ah. Thats it. I was refering to rChangeLogEntry and not "Change Log Entry". ](*,)

    Thanks kapamarou
  • kapamaroukapamarou Member Posts: 1,152
    You're welcome...
    Just mark your post as solved...
    :D
Sign In or Register to comment.