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
0
Comments
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 helps
Even if it could I don't think this would solve my problem. As setting hte subform to 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.
You need to enable the DelayedInsert property on the subform...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
and it works perfect for me.
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?
/EC
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.
/EC
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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.
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.
The solution (from related mibuso posts): set DelayedInsert to Yes on the subform.