Hi,
I have form 26 and need via another table decide whether fields on the form must be editable or not.
In a new table/form users can select a list of fields from record 23.
When users then open form 26, I need to code that if a field exists in this new table then the field on the form must be editable.
First I have set all the fields to non-editable and on OpenForm I have done following:
OnOpenForm
lv_RecRef.GETTABLE(Rec);
F_ActivateFields(RecRef);
F_ActivateFields(RecRef)(VAR lv_RecRef : RecordRef)
lr_TemplateHeader.SETRANGE(TableID,lv_RecRef.NUMBER);
if lr_TemplateHeader.findfirst then
F_UpdateFields(lr_TemplateHeader,lv_RecRef);
F_UpdateFields(lr_Template : Record Field Template Header; VAR lv_RecRef : RecordRef)
lr_TemplateLine.SETRANGE("Data Template Code",lr_TemplateHeader.Code);
lr_TemplateLine.setrange(Type,TemplateLine.Type::Field);
IF lr_TemplateLine.FINDFirst THEN
REPEAT
IF lr_TemplateLine.FieldID <> 0 THEN BEGIN
[what happens here ???]
END
UNTIL lr_TemplateLine.NEXT = 0;
I am not sure what to do next, so that I can do following on every field on the form:
CurrForm.Name.EDITABLE(true);
Thanks
Ann
0
Comments
I prefer to put such code in OnFormat trigger of controls.
Example:
Value - OnFormat(VAR Text : Text[1024];)
You can use:
CurrForm.Value.UPDATEEDITABLE(TRUE/FALSE);
GoodLuck
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Not sure if this is on the same track but I have a start date on the item card. As soon as someone enters a price in the item price tabel I wanted the start-date to no longer be editable.
So First I added a flowfield to the item card to see if that item # "EXISTS" on the other table, called it "Prices Exist". If it does then the flowfield shows it as checked on the item card. From there I can easily check.
If "Prices Exist"
then CurrForm."Start Date".Editable(False)
Else CurrForm."Start Date".Editable(True);
http://www.BiloBeauty.com
http://www.autismspeaks.org
The fields should be "editable" by default, and what you should do is setting them as non-editable when you want them not to be changed. That way if the field is already non-editable (example, a flowfield or a non-editable field or calculation), it won't break with an error when trying to make it editable. Basically... if it's editable, you do nothing. If not, you make it non-editable.
BTW... on aftergetrecord is your friend to call a function that just sets the fields to editable or not.