Disabling a field when some condition is true

aliennav
Member Posts: 449
Can we diable a field when some condition is satisfied?
Suppose i have checked a check box ,now i want some text field to be non- editable.
What can be done for it?
Suppose i have checked a check box ,now i want some text field to be non- editable.
What can be done for it?
0
Comments
-
Hi
in the OnAfterValidate of the check boxCurrForm.MyField.Enabled := TRUE; IF Disable THEN CurrForm.MyField.Enabled := FALSE;
Hope this helps0 -
And it is table form or card form?
Do not forget to refresh editable property when record is changed (OnAfterGetCurrRecord).0 -
Hi Kine Sir,
I have the above issue with Currform.Field.Enabled property based on condition. And my code as
IF "Item Type" = "Item Type"::"Filter Plate" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);;
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Filter Cloth" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Cylinder THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Power Pack" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Valves THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"PLC Panel" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Frame THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Make.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE)
END ELSE
IF "Item Type" = "Item Type"::Instruments THEN BEGIN
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END;
Its not working properly when i do enter item type or when i click on next rec view.
Each time I choose the rec from list to card, only when i run it again it works fine.
Is it possible to make work on all cases?
Thanks & Regards,
Jaanu0 -
1st: "opening" 7 years old topic is not much optimal... ;-)
2nd: you are showing the code to set the properties, but the problem is "from where you call this code". And you are not mention this...
3rd: what about using Case command instead of the not nice if-then-else-if-then-else chain? ;-)0 -
OK Sir. I will change my code. Since i'm a beginner in coding, i started with if else.
I Wrote the above code in Item type field OnValidate & also in On AfterGetCurrRecord.0 -
Another thing: you are setting everywhere FALSE. Where are you enabling them?
One TIP: create function like SetControlEnabled(param), put the code there, and from the Case just call the function with correct parameter. This Copy&Paste code is not good. Do not forget to make the code reusable...0 -
For each type, few fields have to be disabled.
Ok sir. I will try as you said.
Thanks,
Jaanu0 -
Please, do not do what I said, but think about it. It seems, like you want some fields to disable, and some enable. But everywhere in your code there is parameter FALSE. Where is call with TRUE? You must ENABLE the fields somewhere, else you disable them all when going between records...0
-
thank you sir. I have done with my task.
i left the fields which has to be enabled on type option.
0 -
Its not working in my case as well..0
-
You should open a new topic for your case, others will help you with it.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