Control fields on a form

dabba23
Member Posts: 77
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
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
-
HI dabba23
I prefer to put such code in OnFormat trigger of controls.
Example:
Value - OnFormat(VAR Text : Text[1024];)IF Value<5 THEN CurrForm.Value.UPDATEFORECOLOR(255) ELSE IF Value>20 THEN CurrForm.Value.UPDATEFORECOLOR(65280) ELSE CurrForm.Value.UPDATEFORECOLOR(0);
You can use:
CurrForm.Value.UPDATEEDITABLE(TRUE/FALSE);
GoodLuck0 -
Problem is that there is no dynamic way to access controls on the form. It means that there is no generic way how to do that. You need to create some specific code for each control on the form in design time...0
-
Are you talking if the vendor # already exists then not-editable??
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);0 -
You are using the wrong approach.
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.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions