get data from subform

gmorkengmorken Member Posts: 38
Hello,

On Form 42 sales order, I would like to access nr. field in form 46 sales order subform. Can I call the subform from my mainform in any way?

Regards
Tomas

Comments

  • DatapacDatapac Member Posts: 97
    Create a function in your subform that simply returns the field you're looking for (e.g. EXIT("Line No.") will return the Sales Order line no). On your main form, call this function as follows:

    ReturnVal := CurrForm."Subform Name".FORM."Function Name";

    Hope this helps,
    Richie
  • gmorkengmorken Member Posts: 38
    ok thx but I get an error message using this syntax.
    var
    mySubForm = FORM, Sales Order Subform


    returnVal := CurrForm.mySubForm.FORM.returnLineNr;

    in Sales Order Subform I have declare a function called returnLineNr
    with syntax EXIT("Line No.");

    The error message is
    "You have specified an unknown variable" mySubForm

    The variable is defined in globals.
    Cant I use this syntax in Nav 3.6?
  • DatapacDatapac Member Posts: 97
    I don't use variables to reference the subform, but rather reference the subform control on the main form.

    From Form 42:
    SalesLineNo := CurrForm.SalesLines.FORM.getlineno;

    where SalesLineNo is an integer variable and getlineno is a function on Form 46 that returns the line no.
  • ArhontisArhontis Member Posts: 667
    Datapac is correct...

    Remove the variable mySubForm, click on the subform control, go to View->Properties, look at the Name property of the control (it should be SalesLines) and look in your code, you should call something like:
    returnVal := CurrForm.SalesLines.FORM.returnLineNr
    

    By using the actual subform control on the form, you get data from the current record that the user has selected...
  • gmorkengmorken Member Posts: 38
    Ahhh now I get it and it works great!
    Thanks all
Sign In or Register to comment.