Basic question.... Form<->SubForm

abartonicek
abartonicek Member Posts: 162
edited 2005-12-22 in Navision Attain
I have Header table and Lines table.
I have form from Header table with subform from Lines table.
Classic, wright.

The PK in Header table is DocNo.
The PK in Lines table is DocNo.,LineNo.

Form to subform link is DocNo.=FIELD(DocNo.)

How(and where and in what trigger) to auto fill subform DocNo. increment LineNo.

I used DocNo := GETFILTER(DocNo.) in OnNewRecord but I'm getting wierd results so.. :?:
Help.
Better to be critical then self-critical :)

Answers

  • Marije_Brummel
    Marije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You need to activite the autosplitkey property on the subform.


    PS.

    I hope the fieldname is Document No. and not DocNo

    Please follow the Navision guidlines....
  • abartonicek
    abartonicek Member Posts: 162
    Doesn't work :?:
    SubForm:
    Autosplitkey is ON
    DocNo. :=GETFILTER(DocNo.)  in OnNewRecord
    

    The DocNo doesn't get filled and the record is filltered out from subform.

    When the code is in OnAfterGetRecord then the field is filled but the form is acting funny, filling all lines in subform and when I want to change something I get error that that LineNo allready exists.

    PS.
    DocNo is just for this posts.
    Better to be critical then self-critical :)
  • sgg
    sgg Member Posts: 109
    edited 2005-12-21
    Once you have set the subform link to Document No. and AutoSplitKey is enabled on the SubForm, You Do NOT need any codes to create the Line Numbers and Document Numbers.

    It will be automatically Done.

    Try Removing your codes.
    Sunday, Godwin G
  • Marije_Brummel
    Marije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, try to remove the code and if there is any, the tableview in the subform.
  • abartonicek
    abartonicek Member Posts: 162
    Works =D>
    Realy didn't know that, thx.
    Better to be critical then self-critical :)
  • DenSter
    DenSter Member Posts: 8,307
    All you need is:
    Header table PK = DocNo
    Line table PK is DocNo, LineNo (must be integer type!)

    Form with source table Header, and a form with source table line, don't think about subform yet. Set the Autosplitkey property of your line form to yes.

    On your header form, create subform control and set the form id to the line form. In the formlink property you set the filter on Header.DocNo = FILTER(Line.DocNo).

    This should take care of the auto numbering. There is no need for ANY coding at all.
  • DenSter
    DenSter Member Posts: 8,307
    <edit>deleted because of double posting</edit>
  • Marije_Brummel
    Marije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Double posting AND one minute to late :mrgreen:

    But intentions were great. =D>
  • DenSter
    DenSter Member Posts: 8,307
    thanks, I didn't even have Navision open either ;)
  • shilpareddy
    shilpareddy Member Posts: 28
    edited 2005-12-22
    DenSter wrote:
    All you need is:
    Header table PK = DocNo
    Line table PK is DocNo, LineNo (must be integer type!)

    The last field in the primary field must be an integer BigInteger, GUID or decimal field. If these conditions are met, you can set Autosplit key property to Yes.
    With Regards,
    Shilpa Reddy
  • shilpareddy
    shilpareddy Member Posts: 28
    DenSter wrote:
    All you need is:
    Header table PK = DocNo
    Line table PK is DocNo, LineNo (must be integer type!)

    The last field in the primary field must be an integer BigInteger, GUID or decimal field. If these conditions are met, you can set Autosplit key property to Yes
    With Regards,
    Shilpa Reddy