Preventing editable lookup forms
You may want users to only add records when running a form from a setup location. This example will show you how to prevent users from adding or modifying values when only trying to look up a record.
Getting ready
This example will use the Salesperson/Purchasers form (14).
How to do it...
Design the Salesperson/Purchasers form from Object Designer.
In the
OnOpen
trigger for the form, add the following code:IF CurrForm.LOOKUPMODE THEN CurrForm.EDITABLE := FALSE;
Save and close the form.
How it works...
The code here is pretty self-explanatory. If the form is in lookup mode, it will not be editable.
There's more...
The Lookup mode is a special mode in which forms can run. Essentially, when in lookup mode, the OK and Cancel buttons are displayed; when not in lookup mode, they are hidden. When using these buttons you can retrieve the selected value from the form. It is often a good idea to make forms uneditable in lookup mode, although you will find many forms in base...