Change Button won't DISABLE

I am having trouble getting a button in a window to be disabled. All of the conditions are met for disablement, the code gets executed, but the button stays enabled.

Here’s the code:

! Machine Quals checks
CLEAR(Qua:CAM_Num) ; CLEAR(Qua:MachineName) 
Qua:CAM_Num = GLO:CAM_Num
    IF Qua:CAM_Num = GLO:CAM_Num AND CLIP(Sch:MachineName) = CLIP(Qua:MachineName) !OR GLO:ADMIN = 1
        !CLEAR(Qua:CAM_Num) ; CLEAR(Qua:MachineName) ; CLEAR(Qua:Qualified)
        message('should enable')

    MESSAGE('Qua:CAM_Num = ' & Qua:CAM_Num & '|' & 'GLO:CAM_Num = ' & GLO:CAM_Num & '|' & 'Sch:MachineName = ' & Sch:MachineName & '|' & 'Qua:MachineName = ' & Qua:MachineName)   
    IF Qua:CAM_Num = GLO:CAM_Num
            MESSAGE('You are not qualified to use this machine.')
            DO RefreshWindow


The button of interest is ?Change, but I notice that ?Change:2 has #ORIG(?Change) in its window definition. Do you think that ORIG designation is confusing things?

BUTTON('&Change'),AT(133,172,49,14),USE(?Change:2),LEFT,ICON('WACHANGE.ICO'),DEFAULT, |DISABLE,FLAT,HIDE,MSG('Change the Record'),SKIP,TIP('Change the Record'),#LINK(?Delete:2), |

BUTTON('&Add/Change Sessions Booked'),AT(346,182,120,14),USE(?Change),LEFT,ICON('WACHANGE.ICO'), |
            MSG('Add or Change Sessions for the highlighted Machine'),TIP('Add or Chang' & |
            'e Sessions for the highlighted Machine'),#ORIG(?Change),#SEQ(22),#ORDINAL(14)

No @ORIG is not the problem.

I assume the Change Button is part of a Browse Template ? The Browse code checks if there are Any Records showing then sets the Change and Delete button Disabled = True/False. If there are no records there is no point in the Change button working. So that Browse feature is overriding your setting Change Disabled.

You can override that behavior, but the code required depends on if its ABC or Legacy ? ABC is managed (encapsulated) in the ABBrowse class as BrowseClass.ChangeControl.

IMO disabling Change leaves a mystery for the User (and Tech support) as to why it cannot be done… What I prefer to do is leave Change enabled, then put that kind of code under the Change button and show an obvious Message('You cannot change this because xxxx')

1 Like

I can see both ways of going.

The MESSAGE() works well for telling a user what they’re missing by not upgrading their license, but I am more for the disabling/hiding in regular usage. A status panel could tell them why it’s disabled. As a user, I’d rather know (by the visual disabled cue) that I can’t click something than to waste two or more clicks to find out that info.

In ABC put your code to Disable the Change button in the Browse Class UpdateWindow method after the Parent call.

1 Like

I am using Legacy Templates.

The odd thing about this problem is that I had added a button to the window whose sole purpose was to DISABLE the ?Change button and it most certainly worked. Don’t know why I cant do it from code.

Carl, yes the button is part of a browse template and all of the tps files involved are populated with data. I think the message that the user gets will explain why they cannot add/edit a record. The code is checking to see if a person has been trained for use of a woodworking machine prior to letting them schedule time on the machine. The QUA: file contains a userID and a machine Name. This file is consulted when people click on a date (in a browse) that a particular machine will be in use. If that machine is not in the QUA file with the persons’ ID, then they are not qualified to use the machine and should get the message and a DISABLED button. The button that gets disabled is one that leads them to a child file (of the Date/machine file) that contains time slots they can reserves.

In the Embeditor search for ?Change and you’ll find code like below that sets the Change Disable = 0 or 1 in BRW1::RefreshPage Routine:


I would think you do NOT want your code down there. You want to do it early and set a Local Variable Flag that you use down there.

With your Change Disable in effect test Right-Click on the Browse and in the Popup Menu selecting “Change”. IIRC in Legacy the Popup does not check if Change is disabled. Certainly other code may POST(Event:Accepted, ?Change) and execute the code when its disabled.

To be safe in the Change button Accepted Before Generated Code embed I test IF ?Change{PROP:Disable} or ?Change{PROP:Hide} THEN CYCLE.

1 Like