Options

Changing the Label Caption on a form

SteveSteve Member Posts: 81
Hello,

I need to change a label caption on a tabular form when the user selects specific filters. I can test for each filter case, but I can't seem to figure out how to change the label caption for a field within the tabluar form on the fly. I can't use the captioning system since the field name isn't determined until after the user performs a filter selcetion and the form is loaded.

Thanks #-o
Steve

Comments

  • Options
    eromeineromein Member Posts: 589
    Could you maybe explain a bit more detailed?
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • Options
    RobertMoRobertMo Member Posts: 484
    You can utilize "CaptionClass" property.
    Check this property for captions for Shortcut Dimensions 3,4,5… in let say “Purchase Order Subform”. These are changed on-the-fly.
    Then study the codeunit 1.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    SteveSteve Member Posts: 81
    1. I can't use the shortcut dimension since the information for filtering is on the form level and codeunit 1 assumes that the same data( caption ) is always in the same field. I wouldn't be able to call back to the form object and get the current filters.

    I create a field that the user can filter on any dimension and that data will fill this field and then the user can use Navi F7 functions to further filter is needed. So this one field can display data from ( Examples, Department, project, area, business group, etc...) all in the same field.

    This leaves me with one problem, the caption. When the user selects to filter "AREA" I would like the caption for this field in a tabular form to change and say AREA or DEPARTMENT when DEPARTMENT is selected and so on.

    I hope this further explains my dilemma.

    Steve :?
    Steve
  • Options
    RobertMoRobertMo Member Posts: 484
    I meant to explore Dimension caption and CU1 not to directly use them...

    Well I will give you an example that should help. I hope. :wink:

    Choose any control on form and set it's Caption Class (including starting '):
    '9,MyCaption: '+Rec.GETFILTERS
    
    Then open the Codeunit 1 and change the function "CaptionClassTranslate". You should add your own CASE option. The function should read:
    CaptionClassTranslate(Language : Integer;CaptionExpr : Text[80]) : Text[80]
    CommaPosition := STRPOS(CaptionExpr,',');
    IF (CommaPosition > 0) THEN BEGIN
      CaptionArea := COPYSTR(CaptionExpr,1,CommaPosition - 1);
      CaptionRef := COPYSTR(CaptionExpr,CommaPosition + 1);
      CASE CaptionArea OF
        '1' : EXIT(DimCaptionClassTranslate(Language,CaptionRef));
        '2' : EXIT(VATCaptionClassTranslate(Language,CaptionRef));
    //>Start of change
        '9' : EXIT(CaptionRef);
    //<End of change
      END;
    END;
    EXIT('');
    

    [-( Now try what happens to your Caption when setting different filters.

    Remark1. See that the number before the comma in CaptionClass (in this case 9) identifies the CASE option.
    Remark2. Be sure to at least close and open company to refresh CU1.
    Remark3. Your caption cannot be longer then 80 chars, so beware of setting too much filters.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    RobertMoRobertMo Member Posts: 484
    Now the trick :whistle:
    Instead of:
    '9,MyCaption: '+Rec.GETFILTERS
    
    write your own function that returns a text string you want to display as caption and use it in Caption Class like:
    '9,'+Rec.MyFunctionThatReturnsRightCaption
    
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Options
    SteveSteve Member Posts: 81
    Much appreciated....
    Steve
  • Options
    fbfb Member Posts: 246
    ...and remember to call CurrForm.UPDATECONTROLS; if something happens in the form that may change the caption value...

    On further thought, aren't you doing something that is very close to what Form 554 does with the 'DimXFilter' fields? These fields can be used to set filters on 'arbitrary' dimensions -- in this case, the dimension specified in the Analysis View record. Just a thought...
Sign In or Register to comment.