From the sales invoice header I have a field that looks up to another form. On the second form I have a global for the user to enter an amount. When the use closes the second form I want to send the value in the global back to the sales invoice header and populate a field in the table. Any ideas on the best way to do this?
Hi Lori, when you are talking about a field, that you want to retrieve from the second form, it can be done like this:
If Form.RUNMODAL(0, tableoffrom2) = ACTION::LookupOK THEN MESSAGE(tableofform2.field);
When it is a variable, there is some more coding needed In the first form you define the second form as a variable and run it this way:
Form2.LOOKUPMODE(TRUE); IF Form2.RUNMODAL = ACTION::LookupOK THEN MESSAGE(Form2.GetValue); CLEAR(Form2);
In the second form you declare a Function:
**GetValue() : Text** EXIT(Value)
Reijer suggestion is right on. It works only because you are declaring a variable of FORM type. It will not work using FORM.RUNMODAL(FORM::“MY FORM”,REC); What allows it to work is because it is a variable even when the form is closed, the form is still “alive” in memory. Bill Benefiel Manager of Information Systems Overhead Door Company firstname.lastname@example.org (317) 842-7444 ext 117
I really appreciate the help, however, I can’t get this to work. I put the code you suggested in the OnLookUp trigger of the field on the first form. Is this correct? When I run debug and it gets to running the function, my variable is zero. Any help? Thanks, Lori
Did you make a function in the second form also? Please post your code so we can look at it and help you further.
Here is the code that I have on the sales invoice form which is the first form. The second form runs off the job ledger entry table. JobLedger.SETCURRENTKEY(“Job No.”,“Entry Type”,“Posting Date”); JobLedger.SETRANGE(“Job No.”,“Job No.”); JobLedger.SETRANGE(“Entry Type”,JobLedger.“Entry Type”::Prepayment); PrePayForm.LOOKUPMODE(TRUE); IF PrePayForm.RUNMODAL = ACTION::LookupOK THEN “Prepayment Amount” := PrePayForm.GetPrePayAmt; CLEAR(PrePayForm); Here is the function on the second form. GetPrePayAmt() : Decimal EXIT(PrePayAmt); Thanks again for your help, Lori