Prevent subform from loading

EC
Member Posts: 56
Sorry for spamming the forum :-)
Does anyone know how to prevent a subform from loading?
I have a subform which i want to be shown if the user selects a special option, otherwise the subform should not be shown. If the subform is loaded when the user has selected anything but the special option, an error occurs as the subform tries to filter/find some records (acording to the selection) that does not exist.
Any way to prevent this?
I hope you understand what i mean.
/EC
Does anyone know how to prevent a subform from loading?
I have a subform which i want to be shown if the user selects a special option, otherwise the subform should not be shown. If the subform is loaded when the user has selected anything but the special option, an error occurs as the subform tries to filter/find some records (acording to the selection) that does not exist.
Any way to prevent this?
I hope you understand what i mean.
/EC
0
Comments
-
1. Name your subform.
2. On the OnInit trigger of your form put this code.
CurrForm.YourSubformName.VISIBLE := FALSE;
3. On the Validate Trigger of your Option Button put this code
CurrForm.YourSubformName.VISIBLE := TRUE;
Hope this helpsNo future at CPI0 -
I can't. The following error occurs "The form can't recognize the controlelement XXXXXXX".
Even if it could I don't think this would solve my problem. As setting hte subform toVISIBLE := FALSE;
will not prevent the subform fron loading, and when it loads it sets the range according to what the user selected. If the user selects anything but the special option, the subform will fail and then close.0 -
The problem is somewhere else - why the subform is creating error? You can solve this problem... :-)
You need to enable the DelayedInsert property on the subform...0 -
The error occurs because I've set SubFormLink om my subform. Is there any other to setting this programmatically?0
-
I normally use a combination of ENABLED and VISIBLE
IF Status = Status::Active THEN CurrForm.Subform.ENABLED := TRUE ELSE CurrForm.Subform.ENABLED := FALSEE; CurrForm.Subform.VISIBLE := CurrForm.Subform.ENABLED;
and it works perfect for me.0 -
Torben,
Although it is a good solution, it doesn't solve my problem. The subform somehow still loads (although neither Enabled or Visible). An error still occurs as the subform tries to sort by an invalid value.
E.g. My subform's SubFormLink is set to Status = FIELD(Status).
In the table that the subform represents there are only values where Status is = Active.
If the user chooses status = Inactive the subform fails with an error saying something like "Status 'Inactive' doesn't exist'.
Does this clarify my problem a bit?
/EC0 -
It seems like you have not synchronous options on the fields you are linking or there is not correct code setting the filters. Try to enable debugger, run the form, simulate the problem and look where the debugger will stop. After that, try to send us the code where is the problem (if it is in code). Else you are linking fields with different options...0
-
Kine,
I have tried debugging and it doesn't seem the problem is in code but in the SubFormLink. The problem is that the subformlink only applies to when a specific value is set, f.ex. Active. If value is set to Inactive the subformlink does not apply and will yield no result.
That's why I want to prevent the subform from loading.
/EC0 -
Can you post OptionStringML for the <your header>.STATUS field and <your lines>.STATUS field?0
-
Well, the thing is that I only want to show the subform if the status equals Active. Otherwise I don't wanna load the subform as this generates the error I'm getting.
So my header has several OptionStrings. Lets call them Opt1, Opt2, Opt3.
The subform in question has subformlink set to Status = Field(Opt1).
If the user user Opt2, the subform loads and the before-mentioned error occurs. Because Status = Opt2 does not exist in the table represented by the subform.0 -
Ok, than, it is better to filter the subform through TableView (SubFormView) with fixed filter and do not use this in SubformLink...0
-
Actually, I just discovered that the table filters on a order Number.
This order number exists if status is set to Active, but not when set to Inactive.
Then the subform fails as the order number does not exist. Sorry for the confusion.0 -
There must be some other problem - if a filter has an empty record set, that should not throw an error - if it did that, you could never look at an invoice form with zero lines.0
-
EC, did you find the solution to your problem ? I'm having the exact same problem and I don't understand why.
I can't see the difference between what I try to do and a SalesHeader/SalesLine master detail form, yet there must be something different.0 -
Well this topic is quite old, but i've had exactly the same problem -
The solution (from related mibuso posts): set DelayedInsert to Yes on the subform.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