Linking Maintable to Subtable

unplugged
unplugged Member Posts: 4
Hi folks,
I have just a simple problem I found no answer in this forum.

Two Tables
01 Maintable the primary key is an code, every entry may has few subtable-entries
02 Subtable

Two Forms
01 The mainform has a 02 subform (subtable-items) which shows all subtable-entries concerning the mainform-item

I'd linke to create a new entry in the subform but the new entry needs the info from what main-item it is created (the subtable-entry should belong to the main-entry)

I need some code like:

In the sub-form OnNewRecord: subtable.trigger_to_maintable_item :=main_entry_code

Answers

  • jekingcom
    jekingcom Member Posts: 18
    Go to the properties for the subform, and select the sub form and link properties. This will automatically create the foreign keys on the subform. Take a look at the invoice card to see how this is done specifically.
    *************************************
    NAV, CRM, MOSS, CMS, Commerce Server
    Justin King
    Brulant, Inc
    www.brulant.com
    justin.king at brulant.com
  • unplugged
    unplugged Member Posts: 4
    Hi jekingcom,
    Thanks for your reply.
    My settings in the main-form - here the sub-form-properties:
    SubFormID: MySubform-ID
    SubFormView: emty
    SubFormLink: Main-Table-PrimaryKey=FIELD(Sub-Table-PrimaryKey)

    The sub-entries are not filled with the reference-main-table-entry...

    The invoice card? No card is named so. Sorry, I am a beginner...
  • unplugged
    unplugged Member Posts: 4
    Bloody beginner's mistake. :roll:
    In the sub-table should exist a key like subform-pk,reference-field-to-main-table (example table 43)
    Right now it works fine without tranfering data from the main-form to the subform, even though it would be possible by a sub-table-function which is called by the main-form... :whistle: