Locking SubFormID from Editing

Could somebody tell me how to lock SubFormID (Sales Line Subform) from any editing if 1 field (data type boolean) in the Sales Header is check on? I have created 1 field in the Sales Header called “Accounting Approval”. The purpose of this new field is to control some orders that need Accounting approval (For orders with Prepay Shipment that we responsible to pay the freight). Once those particular orders was approved by Accounting, then, there are NO CHANGES could be made in the Sales Header and Sales Line. Both tables are only available for any editing if the “Accounting Approval” field is marked as FALSE, which is unchecked. I could lock the Sales Header but struggling to lock the Sales Line. What I want to do is locking the whole Sales Line SubFormID once the “Accounting Approval” in the Sales Header is checked by Accounting. Thank you for the help! [:D]

you can put something like this in the SalesHeader Form, in the Form - OnAfterGetRecord Trigger (and Probably in the Field OnValidate Trigger of the “Accounting Approval” as well): IF “Accounting Approval” THEN CurrForm.SalesLines.EDITABLE(FALSE) ELSE CurrForm.SalesLines.EDITABLE(TRUE); Regards Daniel

Or: CurrForm.SalesLines.EDITABLE(NOT “Accounting Approval”);

Both Daniels, Thank you very much for the help. [Wow!] Panca

Could somebody tell me the command if I want to lock some fields only, for example Quantity. I tried: CurrForm.SalesLines.“Quantity”.EDITABLE(FALSE) but it didn’t work for me. Thx, Zen

The sales lines subform is a control in the sales header form and you have access to those controls from the sales header form. You want to access the controls of the subform from the main form and that isn’t possible. You need to do your programming in the subform. Then you are able to use CurrForm"Quantity".EDITABLE(FALSE).

Thank you Peter, it’s works. I learned something new from you. Zen [:D]

I am developing some modifications for Sales Order, once the status of the order was released (thru Function - Release) and approved by supervisor (datatype boolean), then, there no changes could be made in Sales Header and Sales Line, everything would be non editable until somebody with a permission change the order status “open” thru the Function - Reopen (code unit 414). My problem is how to make the sales order subform (form 46) back become editable when the status is now opened. Could somebody help? Thanks - Zen

If the reopen function is called from the sales order form and that function sets Accounting approval back to false you can use this again:

quote:

Or: CurrForm.SalesLines.EDITABLE(NOT “Accounting Approval”);
Originally posted by DenSter - 2005 Oct 18 : 12:41:58

Maybe a strategically placed CurrForm.UPDATE is necessary to make it work.

The purpose of this modification, we don’t want to set “accounting approval” back to false once the order is approved. The reason for making the fields becomes non editable is mainly for Customer Service and Logistic. But, for A/R Dept, they need to have the capability to unlock the Sales Line for inserting any additional charges (mainly G/L Account) that might be applied to that particular order. I am planning to unlock the Sales Line for A/R becomes editable thru the Function - Reopen (codeunit 414) but I don’t know what is the command. Please advise. Thx - Zen

In that case you have or want to make a field Status and use that to lock / unlock your subform. The only thing in code that changes then is the fieldname.