How to select a option box?

Hi,

I try to select a radio button(Option button).

I try it like this: CurrForm.“Bestaand afleveradres”.CHECKED = TRUE;

But that doesnt work.

Thank you

what about
Selection := Selection::Closed;

where closed is option which you want to check

selection is field.

I dont understand. The name of the control is: Bestaand afleveradres"

can you show the screenshot of the scenario?

I attached a image

Can somebody give advise? Wiil be nice

Hi Niels,
I would love to give you an advise. But I have read your post a few times, and the replies. Not really sure what your questions and what it is that you’re trying to do?

You already have control on the form. So to select it you just have to click it! So that can’t be your question.

So are you instead trying to select the value via code?

In that case to assign (or select) the option box via code, then you just have to assign true to the field or variable of the box. And then “Your field” := TRUE;

Hi,

Read this link: msdn.microsoft.com/…/dd338709.aspx

This Example is HelpFul to make Option Box.

“Bestaand afleveradres” and “Emailing Addres” should have same Expresssion, but diferent valueoption.
For Example “Bestaand afleveradres” set option Value = ‘Bestaand afleveradres’ and “Emailing Addres” Set Optionvalue = ‘Emailing Addres’.

IF Expression = “Bestaand afleveradres” THEN
Do Something.

“Bestaand afleveradres” should be handled as a MLCaption. The option values are always in English. Regardless of the user language.

Thank you.

I have it now like this:

IF Option = 1 THEN
MESSAGE(‘hallo’);
IF Option = 2 THEN
MESSAGE(‘hallo2’);

And I set by the option boxes respectively: 1 and 0.

But now they stay selected, if I press on one of them

Hi Niels,

Options “Bestaand afleveradres” and “Emailing Adres” must have same field on Expression properties but diferent OptionValue.

For Example:

  1. Add an field on table or ad an variable on global with name “TypeOfSending” or watever you want, with DataType: Boolean or Option or watever you want.
  2. Add to Option button on Form. In two option buttons on Expression Properties set “TypeOfSending” as expression.
  3. On option 1 at OptionValue properties set “Yes” for true value if you use boolean as expression.
    On option 2 at OptionValue properties set “No” for true value if you use boolean as expression.

OnAfterValidate trigger of two option buttons set code:
IF TypeOfSending = TRUE THEN
MESSAGE(‘hallo’)
ELSE IF TypeOfSending = FALSE THEN
MESSAGE(‘hallo2’);

Hi Niels,
You still haven’t explained exactly what “Bestaand afleveradres” and “Emailing Adres” is?
What I think you’re trying to do (having a field which is basically on or off, either one value or the other value, either “Bestaand afleveradres” or “Emailing Adres”) could be done in two ways. Either “Bestaand afleveradres” and “Emailing Adres” are each a boolean field in your table (36?) or you create one option field with the two “controls” as different option values.

Using Boolean fields:
If you are using the first method, then you need to set the other option to off via the field triggers like
For: “Emailing Adres”
“Bestaand afleveradres” := NOT “Emailing Adres”;

For: “Bestaand afleveradres”
“Emailing Adres” := NOT “Bestaand afleveradres”;

If done this way, then you just use these fields as the radio button, with the fields as the source. No other code should be required (exept maybe an update on the OnAfterValidate trigger of the form control).

The other way of doing this using an option field is similar to what Xhavat is explaining, but requires a bit more code, to convert the option to booleans first.

PS: And @babrown is of course also right. Rule number one when it comes to NAV programming. All variable and field names including option values, should be in ENU. Local languages should stay in the CaptionsML. :slight_smile:

Hi Niels,

As Erik Said if you have only 2 variables you can use Checkbox instead of Radio buttons or assaign a boolean values

and i think what you want to implement i.e code we already discussed in forums plz follow these links…

Click Here1

Click Here2

Let us Know If You Need Any Help…:slight_smile: