Change the caption of label dynamically

Hi all,

Is this possible in navision to change the caption of lable dynamically.I tried to use caption class property. It works fine with table fields. But if I create a new lable in a form and set the caption class property, it does not work. Can any one assist me to get through this.

Create a text variable and calculate it in Onopen form or onvalidate of any related field

like

IF X=1 THEN

Y := ‘A’

ELSE

Y := ‘B’;

Assign Y vatiable in Name Property and try

Hi Mohana,

No it is not working

What did you do?

can you show us?

Hi Mohana,

I have created a label in a form. I have created a text variable nam. In on open form I have written a code like this.

nam:=‘Name of Customers’;

In the name property of the lable I have set the value to be nam. If I run the form it shows only nam and not “Name of Customers”

Ohh sorry,

May be it works when we have fields in table…

Ok Mohan,

Is there any other way to perform this using caption class property

Use a TextBox instead of a Label and set the SourceExpr to the variable that you want to be the caption.

"If you want to use customized captions on a field, mostly you change Codeunit 1 to do it. I found a way to use customized captions without changing Codeunit 1.

In the CaptionClass Property you have to put ‘1,5,’ + txtMyCaption. Or you can also put a function that returns the string.

Some explanation:

The first parameter says it is a dimension

The second parameter says to use a certain format (= optional parameter 1 + dimension caption + optional parameter 2) of the dimension-code (not value-code!) put in parameter 3.

The third parameter is the dimension-code you want. This parameter must contain a value that does not exist in the dimensions (a blank for example). If this dimension does not exists, codeunit 1 shows the fourth parameter on the caption.

The fourth parameter : the value you want to show as caption."

source: http://www.mibuso.com/forum/viewtopic.php?t=6746

HiAsalli,

I dont want to have customized caption on field but on separate lable on a form.

Did you try my suggestion of using a text box instead of a label? It works exactly as you say you need it to. There is no reason for you to have to use a label control on the form.

Hi Matt,

Actually I know this trick. But I am doing R and D on Caption class property. I want to make use of this property. Can you help me to use this.

If memory serves, the caption class property was introduced to support label controls related to dimensions. I don’t think they were intended to be of any use in any other case. Are you just trying to determine whether you can use the caption class property to manipulate the value of label controls that are not related to dimensions? Just satisfying an intellectual itch maybe? Or, do you have a valid business case for making the caption class work rather than using the obvious solution that Matt offered? If so, we might be in a better position to help if we knew more about your requirements?

This is an attractive question to me. I’ve read through some label text formatting, and I know this must be done by putting the label control with code. However, I still couldn’t work out a good solution for the label control. The suggestions here everyone offers are so helpful. Cheers.