get sub form record from main form

Debbie140Debbie140 Member Posts: 52
edited 2004-04-08 in Navision Attain
I have a main form (card form) and a subform(list form) and in the code behind the main form I am trying to find out which record in the subform has been selected.

Say for instance I need to get the primary key of the record selected on the subform when the user clicks a button on the main form and then use this to do some further processing

I have tried using the currform.subformcontrol.FORM to get a handle on the sub form but this does not seem to work. There must be a simple way to to do this but I can't see it. Advice would be appriciated.

Comments

  • wonmowonmo Member Posts: 139
    Try this:

    On the subform, create a function that acccepts as a parameter whatever value you need and returns that value:

    EXIT(some_parameter_value);

    Call this function on the OnAfterGetCurrRecord trigger of the subform.

    Now, on the main form, when you want to know which record is selected just call that function:

    some_variable := CurrForm.Subform.FORM.subform_function;

    You may also be able to accomplish the same thing with a GETRECORD.
  • Dean_AxonDean_Axon Member Posts: 193
    You may also be able to accomplish the same thing with a GETRECORD.

    Yes you can :D

    Specify a name for your subform and a variable that matches the records in the subform (ie. SalesLines) then the code will be somethnig like this:
    CurrForm.mysubform.getrecord(MyRecord)

    Then your code would use the information from myrecord.
    Remember: Keep it simple
  • Debbie140Debbie140 Member Posts: 52
    Thanks for your answers, both creating function in the subform to return rec.No. and using the CurrForm.SubformControl.FORM.GETRRECORD work.

    I am spolied for choice!
Sign In or Register to comment.