Disabling records depend on values in other fields

Hello All, Should be simple this one but its not quite clicking… I have a field called Sentforapproval. This is boolean. This exists within the Sales Quote subform and within Sales Line. If this is set to TRUE, I want to make the entire record un-editable, if the user goes back into the quote. I have tried various methods including (for example) the setting of the currform.quantity.editable(false) within various sections including OnNextRecord etc. It seems to work for one record but if there are three records in the subform, and not all have Sentforapproval = TRUE, they still get set to editable(false). This is the same if you navigate to another record, even if the particular sentforapproval is set to FALSE, the field in question remains locked. Any ideas? Am I missing something simple?

David, you can not lock just a single record. If you lock a text field or an entire form, this will be effective for all records displayed on the form. However, putting the enable/disable code into the OnAfterGetCurrRecord should do the trick. This trigger is executed upon switching the current record, so the locked fields (or the entire form) should get unlocked whenever the user selects an editable record. The user will not notice any difference, because selecting a record will always update the editable property immediately.

Hello Heinz, Thanks for the reply and the information regarding locking of records etc. However, I have tried your suggested approach and I am still encountering problems. For example, if I go into the Sales Quotes form and my new field Sentforapproval is set to TRUE (ticked) for any of the record lines, the Description field for example, will remain locked for all records, even if I move up and down within the subform. This is also the case if I navigate through the Sales Quote Header i.e. Even if on the next Quote, its sub-lines do not have Sentforapproal set to TRUE, all records have the Description field locked. The code I have within OnAfterGetCurrRecord is: CurrForm.UPDATECONTROLS; IF Sentforapproval = TRUE THEN CurrForm.Description.EDITABLE(FALSE); Is my code the right approach and is there a command that I should be using that acts in the way of a REFRESH?

Have you tried using OnAfterGetRecord instead?

David, is this all you put into the trigger? If yes, then where do you set the field back to EDITABLE(TRUE) again? [:D][:D] I tried this and it works great: IF "Net weight" > 10 THEN CurrForm.Description.EDITABLE(FALSE) ELSE CurrForm.Description.EDITABLE(TRUE);

Heinz, Thank you. I must be still in “weekend” mode. Your help is much appreciated. David

quote:


Originally posted by xorph

 IF "Net weight" > 10 THEN CurrForm.Description.EDITABLE(FALSE) ELSE CurrForm.Description.EDITABLE(TRUE); 

For those of us who are lazy: CurrForm.Description.EDITABLE("Net Weight" <= 10);

quote:


Originally posted by chrisk
For those of us who are lazy: CurrForm.Description.EDITABLE("Net Weight" <= 10);


Oh yes, seems I took the long way home [:I] Your solution, besides being shorter, has the advantage that one can not forget the ELSE-part [:D][:D][:D]