Making a Form Read-Only by User

There may be times when you have application users who should only be allowed to view data on forms and not be allowed to change the data. You need to make forms totally read-only for those users. This section suggests a way to do that.

During development:

·       Include the Toolbar Save button in Controls Security:

·       Set the following property values of the Save button in the Toolbar_All class in the DEVFORMS.VCX or PROFORMS.VCX class library:

·       Enter a Control ID, “E”, in the cCSControlID property.

·       Enter “lAllowEdits” in the cFormAllowProperty property. See below for an explanation of why this is done.

·       Add the Save button to the TOOLBAR_ALL control group on the Security Builder – Control Group Definitions form by adding a record with the following field values:

·       Group ID – TOOLBAR_ALL

·       Control ID – E

·       Control Description – Edit (New, Copy, Save, Cancel)

·       On the Security Builder – Control Security Forms form, assign the Form Toolbar control group (TOOLBAR_ALL) to the forms that need to be read-only for some users.

After the application is installed, set up Controls Security:

·       For the “read-only users”, deny permission for the Edit controls for the forms that need to be read-only. Grant permission for the Edit controls for all other forms.

Tip: If the read-only user should also not be able to delete records on the read-only forms, deny permission for the Delete and Group Delete controls for those forms.

·       For the non-read-only users, grant permission for the Edit controls for all forms.

Then, when a read-only user displays a read-only form, none of the fields on the form will be editable and only the Toolbar Close and record navigation controls will be enabled. A read-only user will not be able to change any data on the read-only forms.

This functionality occurs because when permission is denied for a toolbar control, the form property identified in the control’s cFormAllowProperty property (lAllowEdits in this case) is set to .F.. There is functionality built into the form class that causes the following to occur when the lAllowEdits property is .F.:

·       The New, Copy, More, Save, and Cancel toolbar buttons are disabled, and

·       The controls on the form are disabled so that they cannot be edited.

More:

User Data Encryption