Set Caption

nikeman77nikeman77 Member Posts: 517
Hi guys,

How do i set caption of the field based on location code given that we have different countries with each countries had their own location code.

thus my field caption would like to name after those location code

eg: China: Singapore, Location Code: SH, GZ, BJ

Table:

SH QTY | GZ QTY | BJ QTY

878 | 10,913| 9807

Comments

  • bstnalmbstnalm Member Posts: 25
    Can you use the Matrix-form in NAV?
  • SogSog Member Posts: 1,023
    Edit form of your choice, select a random label, call properties, select captionclass, press F1.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • nikeman77nikeman77 Member Posts: 517
    hi sog,

    thanks for replying.. i try not to modify anything in the codeunit 1
  • dansdans Member Posts: 148
    there is no need to modify Codeunit 1. Add a function, and use the captionclass.
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • nikeman77nikeman77 Member Posts: 517
    hi dans,

    much appreciate your reply..

    i used a function to return code of location:
    so in my table field
    Eg: Location1, caption class i place: GetName(1)
    Location2, caption class i place: GetName(2)

    Result? When I run my table... the field caption is missing?! :o

    Below is my GetName function

    GetName(LocationNumber)Text:30
    Location.SetRange(Code);
    Location.Next(LocationNumber);
    Exit(Location.Code);
  • SogSog Member Posts: 1,023
    It's better to use variables as captionclass.
    And don't forget to call currform.updatecontrols.
    (And F1 is the helpfunction, not codeunit 1)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Sog wrote:
    It's better to use variables as captionclass.
    And don't forget to call currform.updatecontrols.
    (And F1 is the helpfunction, not codeunit 1)

    Wouldn't it be great if all new developers found out about the F1 key. [-o<
    David Singleton
  • SogSog Member Posts: 1,023
    Wouldn't it be great if all new developers PC users found out about the F1 key. [-o<
    Cause F1 is help in most programs :)
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Sog wrote:
    Wouldn't it be great if all new developers PC users found out about the F1 key. [-o<
    Cause F1 is help in most programs :)

    I ran a Developer training course last week. I made very sure that the students pressed F1 at every possible opportunity. The developer online help in Navision is very good, and could probably answer half the questions that people post on MiBuSo. I just can't understand why developers are so afraid to hit that button.
    David Singleton
  • dansdans Member Posts: 148
    Microsoft should just include the question about F1 key on the developer exam, and survey how many people have no idea about F1 key. :D
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • nikeman77nikeman77 Member Posts: 517
    hi guys,

    thanks for replying i will try it out. sorry to sounds so stupid.
    i had used the F1 key in caption class which it says below:

    TranslateCaptionClass(Language : Integer; CaptionClass : Text[80]) : Text[80]

    case Language of

    1036 :

    case CaptionClass of

    'DIM1' : EXIT('Projet');

    'DIM2' : EXIT('Département');

    end;

    1033 :

    case CaptionClass of

    'DIM1' : EXIT('Project');

    'DIM2' : EXIT('Department');

    end;

    end;

    EXIT('');


    if there isnt any modification of the above codes, guess my understanding is it returns a blank.

    i tried suggested methods using variables:
    Location[1] in my caption class properties too, i still turns out blank.

    sorry that it triggers annoyance to you guys. :)
  • dansdans Member Posts: 148
    Well.. it's true that it's a bit hard to understand the concept of CaptionClass in the beginning. You need to take a look at Codeunit 1 to understand it.

    I normally modify codeunit 1 to set the caption. If you do not want to modify the codeunit 1, there is another way to do it. Try putting this on the CaptionClass : '1,5,,' + txtCaption
    Microsoft Certified IT Professional for Microsoft Dynamics NAV

    Just a happy frood who knows where his towel is
  • nikeman77nikeman77 Member Posts: 517
    hi dans,

    as suggest, i modified my caption class to: '1,5,,'+codelocation[1]

    in my table, i have a function setLocation()
    intI:=1;
    Location.SETRANGE(Code);

    IF g_Location.FINDSET THEN BEGIN
    REPEAT
    codeLocation[intI] := Location.Code;
    intI +=1;
    UNTIL Location.NEXT=0;
    END;

    When I run my report to insert sales, purchase history, i add following on report-initreport
    ItemHistory.setLocation();

    after report complete its running, i open up my table, the caption is blank.. :roll:
  • SogSog Member Posts: 1,023
    This is code that has to run on a form.
    If you want to change the caption of a label in a report, use a textbox instead and place the preferred caption in it.
    Captionclass is used in runtime on a form/page
    NAV Help wrote:
    Applies To
    Forms
    Pages
    , not on a report, table, ... . Which means init form, run function, open form, see correct caption.

    Next time, read the help, don't skip to the part where you think the problem is.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • nikeman77nikeman77 Member Posts: 517
    hi sog,

    noted..will go try it out..thanks a lot.. :)
Sign In or Register to comment.