Announcement

Collapse
No announcement yet.

sclProtectAllFields - protects all fields but one check box

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • sclProtectAllFields - protects all fields but one check box

    The attached macro can be used to protect or un-protect all screen fields / objects when a single checkbox is ticked or un-ticked. This may be useful when a field such as a No Data flag is used to indicate a form has no data present. All the other fields can be protected to prevent entry.

    The macro is designed to be controlled by a checkbox object. It allows the name of that controlling checkbox object to be passed as a parameter so that it may be used without hard coding of the name into the macro. It is designed to function only in Enter or Verify modes. It is bypassed when in the Verification process of second key or any other entry modes. It is also bypassed if the record status is verified.

    Parameters
    The macro takes one parameter, keyFiled specified as a named parameter and indicates the name of the controlling checkbox object.

    Setting up the macro
    Download and save the attached SCL macro program sclProtectAllFields.sas into a macro library.

    OnLoad();
    To process the macro when loading existing records, the macro should be called from the screens OnLoad() method as follows:

    Code:
    %sclProtectdAllFields(keyField=CONTROLFIELDNAME);
    where CONTROLFIELDNAME = the checkbox object that initiates protecting or un-protecting of the fields.


    OnLostFocus();
    In order to process the code upon state change of the controlling object (checkbox) the should be called from the objects OnLostFocus() method. Additionally, to keep the system from sending the cursor to a protected field, the _goto method can be called on the current object to send the focus back to it if it is ticked.

    Code:
    %sclProtectdAllFields(keyField=CONTROLFIELDNAME);
    
    ** Set cursor back to field **;
    if _self_.selected = 'Yes' then _self_._goto();

    This macro should be tested thoroughly in all entry modes to ensure if functions as expected.
    Attached Files
Working...
X