Options

Obtain data from form

lubostlubost Member Posts: 615
My problem is following:

1. I have Table no, Field no and Form no stored in record
2. I want to run a form Form No in lookup mode
3. I want to obtain a value of Field no from selected record

Prerequisitiy : Form's main table is Table no.

Is it way to code it? Thank you

Comments

  • Options
    kinekine Member Posts: 12,562
    I think if you want to do it without modifications of the forms you want to use, there is no way. Problem is that you can not use recordref when calling the form. Than you will need as many record variables as count of possible source tables of the forms.

    But if you can change all the forms with one function, the solution can be done - if you will have one Singleinstance codeunit with functions:

    SetFieldNo
    GetFieldNo
    SetFieldValue
    GetFieldValue

    Which will set global variables in this way:

    SetFieldNo - store required Field no...
    GetFieldNo - read this Field no...
    SetFieldValue - store the value of required Field
    GetFieldValue - read the value back

    You can do something as (pseudo code):
    ...
    FormMgt.SetFieldNo(Table1.FieldNo);
    FORM.RUNMODAL(Table1.FormNo);
    Value := FormMgt.GetFieldValue;
    ...
    
    
    In Form:
    
    OnClose
    
    FieldNo := FormMgt.GetFieldNo;
    <Read Value of Field with No. FieldNo (through RecordRef and FieldRef)>
    FormMgt.SetFieldValue(ValueOfTheField);
    
    

    Where FormMgt is your new SingleINstance codeunit.

    Think about it, it is not so hard. How to exchange data between objects is somewhere in HowTo section...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    SavatageSavatage Member Posts: 7,142
    kine wrote:
    Think about it, it is not so hard. How to exchange data between objects is somewhere in HowTo section...

    http://www.mibuso.com/howto.asp
Sign In or Register to comment.