main and sub form wrt editable property

Hi I have a main form and a subform. The main and subform are linked with a field “No.”. This is only for entry of values. In the table related to lines form i have a field called “document type”. After i enter the values for the header and corresponding lines.I close the form. And when i open it again for modifcations, i want all the lines with document type = job with editable property set to true i mean the entire record should editable on the other hand if “document type” <> job then the entire record should be non editable. In the sense for same header record some lines should be editable true and some lines editable set to false…i mean the entire record should not be editable…i have written code as shown below on the OnAfterGetRecord of the main form JobCostLine.SETRANGE(“Job No.”,“Job No.”); IF JobCostLine.FIND(’-’) THEN BEGIN REPEAT IF JobCostLine.“Document Type” = DocTypeHeader.Job THEN CurrForm.JobCostLines.FORM.EDITABLE(TRUE) ELSE CurrForm.JobCostLines.FORM.EDITABLE(FALSE); UNTIL JobCostLine.NEXT = 0; END; thanks in advance kumar

Do you have some lines for a header that are Document Type = Job and some that are not? First off, for either case, you should not need the REPEAT loop in your code example. If all the lines are Type=Job, just check if the header is Type=Job and set the Editable property on the subform accordingly. If all the lines are not the same Type, then you need to change your coding to go into the OnAfterGetRecord trigger of the Subform. Change the Editable property of the form accordingly. Regards! Kristopher Webb Kelar Corporation, Canada

Hi Kris I do not have Document type on the header table. As you have specified i have first written the code on the OnAfterGetRecord of the subform but the problem was when u open the form the the records are not being distinguished. The code works only when the when the records are traversed on the subform. I mean suppose the first record is not of Document type Job then that record should be non editable. But when i open the form this record is also shown with editable true. only when i traverse the code gets into effect. Thanks in advance …solution needed a bit urgently… Kumar

Take the code you have in OnAfterGetRecord and add it in to the OnAfterGetCurrRecord trigger. Then try deleting the code from OnAfterGetRecord and see what you get. Regards! Kristopher Webb Kelar Corporation, Canada

Hi Kris I have written the code on the onaftergetrecord and it works fine, but the problem is if i wanna enter some more records to the lines for the same header i cant go to the next line (or new record)if the previous line or record in the lines is editable set to false, on the other hand if the last record is editable true, then i can go to the next record and insert a new record in the lines for the same header. solution needed urgently… thanx Kumar Edited by - mvgs on 2002 Jan 25 02:41:59

Hi kumar Your not going to like this but it is a feature of navision that you can not go past the end of a record when a record is not editable. I can not see a way round that and I have tried. You could have a bit of code that will always add a blank line at the end of the offending lines entries so the actual last line is always editable! Paul Baxter

Also I just noticed on my test database make sure you put some code on the OndeleteRecord as you can select all the records and delete them if you put the cursor on an editable record. Paul Baxter

Hi Paul I request u to be more clear with your point on adding coding on the ondelete record…even i found there is no way i can make the next record editable…thanx for the lead Kumar

Hi what I was saying was that even though the record is uneditable you could still delete it. What you need to is not to set the record to uneditable but to set the contols on the form to uneditable when a condition is. It is harder and makes for a big IF THEN ELSE statement. but you do not get the problem of not being able to insert new records. Paul Baxter