making fields Visible and invisible in a subform

SharonVelankanniSharonVelankanni Member Posts: 9
hi,

I have a problem, it would be better if any one help me in this.
I have created a header Form which has a sub Form linked to the Header Form.
I have three fields in the subform table.
I have an integer field in header table. whenever i am updating this field(giving values like 1 or 2 (MAX 3), the fields in the subform should be visible. (depending on the number in the header field).
for instance, if the value in the header field is 2, then only two fields should be visible in the subform.
Can any one help me to solve this?
Regards,
Sharon

Answers

  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from Navision Tips & Tricks forum to Navision forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • XypherXypher Member Posts: 297
    Well I would do something like this...

    Within 'Header Form':
    HdrTbl IntField - OnValidate()
      CurrForm.SubFormCtrl.FORM.UpdateFields("HdrTbl IntField");
    

    Within 'SubForm Form':
    UpdateFields(FieldInt : Integer)
      CurrForm.Field1.VISIBLE := FALSE;
      CurrForm.Field2.VISIBLE := FALSE;
      CurrForm.Field3.VISIBLE := FALSE;
    
      WHILE FieldInt > 0 DO BEGIN
        CASE FieldInt OF
          1:CurrForm.Field1.VISIBLE := TRUE;
          2:CurrForm.Field2.VISIBLE := TRUE;
          3:CurrForm.Field3.VISIBLE := TRUE;
        END;
        FieldInt -= 1;
      END;
    
      CurrForm.UPDATE;
    
  • SharonVelankanniSharonVelankanni Member Posts: 9
    Thanks Xypher.
    The code works really fine.
    But.. if i move to next or previous record(saved records).the fields in the subform are not updating according to the header's integer field.
    is it possible if i write some code in "OnNextRecord" of the header Form?
    can any one help me.
    Regards,
    Sharon
  • distrisoft_larbidistrisoft_larbi Member Posts: 17
    try to use this within the header form:
    Form - OnAfterGetRecord()
    CurrForm.SubFormCtrl.FORM.UpdateFields("HdrTbl IntField");
    
  • SharonVelankanniSharonVelankanni Member Posts: 9
    thanks Xypher , Larbi...

    The code is working fine :D
    Thanks
    Regards,
    Sharon
Sign In or Register to comment.