How to disable a checkbox when another one is checked?

Hi everyone!

I’m a beginner in Nav. I’m working with Nav 2009 R2. I have two checkboxes in a form (male, female). Once you select a determined gender,for example, female, I want to disable the male checkbox. If you then uncheck the female checkbox I want the male checkbox to be enabled again. I hope that I expressed myself clearly because I’m new at this [;)]

Thanks in advance for your help!!

Raquel

Would you not be better using an option box rather than boolean? So the user can select just one of a list?

Neil

Hi Neil!

Thanks for your reply! Yes I thought of that but according to the specifications of the project that I’m working on I have to use two checkboxes. That’s how the boss wants it [*-)]

Hi Raquel,

If you just need disable when other checked you should use Total 4 Boolean Variables :

As like Your Example : one each For MALE(bool1) And Female(bool2)

And Other two For Editable property for Each … And Write Some Code in Onvalidate Triggers Like…

IF bool1 THEN

bool4 := FALSE

ELSE

bool4 := TRUE;

and IF bool2 THEN
bool3 := FALSE
ELSE
bool3 := TRUE;

That’s it Done , If you need anything Let me Know

Hello Raja!

What do you mean by:

And Other two For Editable property for Each … And Write Some Code in Onvalidate Triggers Like…???

I defined the checkboxes with two boolean:

Male type boolean

Female type boolean

Then I defined two global variables:

v_male (type boolean)

v_female (type boolean)

I then wrote the following code in the OnValidate trigger for each checkbox:

OnValidate trigger for Male checkbox:

IF v_maleTHEN Female:=FALSE

ELSE Female:= TRUE;

OnValidate trigger for Female Checkbox:

IF v_femaleTHEN Male:=FALSE

ELSE Male:= TRUE;

But it doesn´t seem to work because when I check one of the options both of them are checked [:(]

I’m a beginner so I really don’t know what I’m doing wrong [:S]

Thanks for all your help!

Hi Raquel,

That is my My Mistake … [:(] Sry you are using 2009 R2 i havent seen That .

But if it is Classic Client Then My suggestion would be like you have created two check Boxes right …

Select First checkbox (see properties let’s say SourceExp Male ) then right click select CALCode

write code

If Male then

Female := False

else Begin

Male := False;

female := False;

End;

Similarly Select Second CheckBox (see properties let’s say SourceExp Female ) then right click select CALCode write code

If Female then

Male := False

else Begin

Male := False;

female := False;

End;

Let Me Know if you got result [:D]

Hi Raja!!

Thanks for the help! Works perfectly fine!!

At the end you only need the two booleans provided by the checkboxes and write the code in the OnValidate trigger for each checkbox.

Thanks once again for your time!!

Best regards,

Raquel

HI Requel

You can also check this post.

http://beginnersnav.blogspot.com/2016/01/v-behaviorurldefaultvmlo.html

Thanks Shyam!!! Very useful