Transfer Value of a variable from one FORM to an other FORM

LeoNavLeoNav Member Posts: 55
Hi, :)

I have a FORM01 and a FORM02. I need to pass a variable from FORM01 to FORM02. How can I do that ?

An idea ?

Answers

  • bbrownbbrown Member Posts: 3,268
    If one form is calling the other (or form/subform) then you can pass it via a function on the called form. If the forms are run separately then you could pass the variable via a single-instance codeunit.
    There are no bugs - only undocumented features.
  • LeoNavLeoNav Member Posts: 55
    In my case, I access the FORM02 by a lookup on field situated on the FORM01. The goal is to do treatment based on the value of the variable I could pass from the FORM01.
    What is a single-instance codeunit ?

    Thanks. :)
  • vijay_gvijay_g Member Posts: 884
    No need to user single instance codeunit (it use for hold value until the application or process running ) you need to make a function in lookup form and then pass value to this form.
  • rhpntrhpnt Member Posts: 688
    LeoNav wrote:
    Hi, :)

    I have a FORM01 and a FORM02. I need to pass a variable from FORM01 to FORM02. How can I do that ?

    An idea ?

    Dear LeoNav,

    maybe you should consider reading some basic documentation on programming NAV before laying hands on it. Read and use the Application Designers Guide included in each NAV installation CD/DVD, NAV online help and countless docs on the web.
  • LeoNavLeoNav Member Posts: 55
    I don't understand how a function can help me to remember a value from the FORM01 and pass it to the other FORM02. In my case I want to do this on the FORM01 :

    1)Rec.Field
    2) store that value in a variable X
    3) reuse the value of the variable X in the FORM02

    :D
  • bbrownbbrown Member Posts: 3,268
    What are you using the value for in form02?
    There are no bugs - only undocumented features.
  • ssinglassingla Member Posts: 2,973
    bbrown wrote:
    What are you using the value for in form02?

    This post seems to be the extension of
    http://mibuso.com/forum/viewtopic.php?f=23&t=45060
    CA Sandeep Singla
    http://ssdynamics.co.in
  • mabl4367mabl4367 Member Posts: 143
    To elaborate on the previous suggestions about using a function to pass the value:

    In FORM1 you have a variable FORM2 of type Form and subtype MyForm and a global variable X of some type;

    In FORM2 you have a global variable X of some type.

    In MyForm create a function fnSetX that takes the new value of X as a parameter lets call the parameter newValue.

    In fnSetX simply do X:=newValue;

    In FORM1 call the function i FORM2 like this:

    FRORM2.fnSetX(X)

    Now the variable X in FORM2 will have the same value as the variable X in FORM1.
  • LeoNavLeoNav Member Posts: 55
    Ok I will try it.

    Thanks. :D
  • LeoNavLeoNav Member Posts: 55
    It works with FORM and SUBFORM but with separate FORM, I can't display the value of the variable used in the function.
  • LeoNavLeoNav Member Posts: 55
    Maybe I'm not very clear. Below is a picture of the 2 forms that I use.

    I want to select multiple records from the form on the right. In order to do it, I use the code at the bottom of the screen. Each FORM is linked to a different table. The one on the left is linked to the table 56204 (primary key : Qualification code, Code, Name). The one on the right is linked to the table Job (167).

    I would like the system to put the records of the multiple selection (on the right side) in the form on the left side. But how does the system know what Qualification code to use to insert the records in the table 56204 ?
    For the moment, I give a static value to it for testing but how can I retrieve the Qualification code selected on the left side and pass it to the right ?

    249f3edc8c68b8226c810a6035e9at.jpg
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Create a new field that will be used to flag the lines. For an example look at Apply Payments in the Customer or Vendor Ledgers.

    Really though you need to understand the business requirement before you start writing even one line of code and even then you need to learn Navision before you write code. If you understood the basic Navision functionality, this would be second nature to you.
    David Singleton
Sign In or Register to comment.