Disable controls on form

sandmansandman Member Posts: 20
Here's my dilemma, :-k

I have a form with many controls on a tab control and button controls below it. I need to disable one of the button controls when certain fields are set a certain way...

3 controls are related. A check mark control, a text field and a button. The first 2 controls are on the tab control and the button is located below it.

If the check mark control is 'checked' and the value of the text control is at '0' then, the button control is disabled....

If the user unchecks the check box or enters a value in the text box, then button is then enabled...

I'm not sure about the sequence of events on a form, i.e. form refresh, load, etc, so i don't know if thats even possible...

Any help would be appreciated
Thanks,

Using Nav 5.0 SP1

Answers

  • matttraxmatttrax Member Posts: 2,309
    There is a property, ENABLED, for the controls on a form. It's a boolean and can be set to anything that resolves to a boolean.

    Button.ENABLED := ( (Box = TRUE) AND (Value = 0) ).

    A better option, though, is to leave the button enabled and check these values in the OnPush trigger. You can then display an error message telling the user what needs to be done. Disabling the button leaves the user on a form with no idea how to make it enabled.
  • sandmansandman Member Posts: 20
    Hmm... Great idea Matttrax! Makes perfect sense.

    Thanks for the info
  • sandmansandman Member Posts: 20
    Here's another question and, please forgive it's newbieness.... :P

    How do you verify the value of a control, whether its a check box or a text box... I've looked everywhere (which is not a lot considering the huge amount (sarcasm) of reference on C/AL... but couldn't find anything!

    Say I have CHECKBOX1 and TEXTBOX1 on FORM1, what would the code look like?

    Thanks again
  • sandmansandman Member Posts: 20
    Oh, and i made a mistake on my first post... I need to verify all this when the user clicks on a MenuButton, not a button control.

    Can I use the 'OnActivate' trigger instead of the 'OnPush' trigger?
  • matttraxmatttrax Member Posts: 2,309
    sandman wrote:
    How do you verify the value of a control

    You don't check the value of a control. Each control is bound to a field or variable (SourceExpr property). You check that against a value.
    sandman wrote:
    I need to verify all this when the user clicks on a MenuButton, not a button control.

    Menu buttons have Menu Data Items which in turn have an OnPush trigger.

    You should read through the Application Developer's Guide from the product CD or the Development I courseware. You'll find some very useful information on Form development there. Good luck.
Sign In or Register to comment.