Running a query on subform and main form

david.weeksdavid.weeks Member Posts: 96
edited 2004-02-23 in Navision Attain
Within a subform, how do I access a field within the Main form and then use the value from that field to query a different table to obtain a value from another field?

For example, i am in the quote lines and i want to retrieve the salesperson code and then use that code to obtain the email address from the salesperson/purchaser table.

Any advice would be appreciated........
(Hopefully, it is as easy as ASP, SQL, VB etc)

Comments

  • pdjpdj Member Posts: 643
    You can't get hold of a control on the mainform from a subform.
    In the mentioned example you don't have to, instead just get hold of the rec on the mainform like this:
    SalesHeader.GET("Document Type","Document No.");
    IF Salesperson.GET(SalesHeader."Salesperson Code") THEN
      IF Salesperson."E-Mail" <> '' THEN BEGIN
        DoWhatever1; 
        DoWhatever2; 
      END;
    

    Isn't that what you meant?
    Regards
    Peter
  • david.weeksdavid.weeks Member Posts: 96
    Hi there,

    That certainly works for some of things I am working on.
    Thanks for your help.

    I will have to try to keep things simple!


    David
  • wonmowonmo Member Posts: 139
    You can also pass the main form primary key value as a parameter to the subform.

    The way to access a procedure/function on a subform is :

    CurrForm.SubformName.FORM.ProcedureName;
Sign In or Register to comment.