Create a’ Second Lookup Form’ with the “Second Field” on display, and then you will need to add code on AssistEdit for the Control or on DrillDown for the form control to populate the Second Value from your new form and new table:
MyNewTable.RESET;
IF FORM.RUNMODAL(MyNewLookupForm, MyNewTable) = ACTION::LookupOK THEN
VALIDATE(“My Second Field”,MyNewTable.“My Second Field”);
The table relation will only work if the Primary Key is included in the relationship, as in Customer.Name where customer.“No.” = “Customer No”
As I read it the OP has a table with two fields and wants to populate two fields on another record with different values from two different records from the new table, which in itself is a strange request, to do this one field can be populated with the primary key and default form, the second could only be populated with code added to the table or form OnLookup or AssistEdit, using a new Second lookup form for the second value, if they want to hide the first field.
Asim, I am still not sure if the first selected value is to populate the “Second Field” with the value from the ‘New Tables’ “Second Field”, then that would be done with the table Field OnValidate trigger.
I think my requirement statement is a bit confusing, I will try again.
Requirement:- while generating purchase invoice, I want to accept two more details about Item. This is master data which I stored into one table (e.g. Field1 and Field2). Now on UI, I want to provide drop down list (that is the reason I have given table relationship) so that user will able to select it and not enter it. The selected value I want to store with purchase invoice.
It sounds like you can just create two normal fields with table relationships in the Purchase Header table. Make sure you have a list form specified in this supplementary table’s LookupFormID and DrillDownFormID properties so that you can do lookup’s.
Hi Asim, you have the new table with two fields, and you have added two new fields to the Purchase Line table, looking at your example when the user selects 7.2 this goes into “Field 1”, now do you want the value in “Field 2” to populate from “Field 2” or for the user to select a new value?
Option 1: Auto Fill or lookup related “Field 2”- use the Code in my second answer above and/or add a table relation, NewTable.“Field 2” where NewTable.“Field 1” = “Field 1”
Option 2: unrelated value into “Field 2” - just use a second table and form.
If this is still not clear give a better example of what you want to do, so we can help.
Hi Asim, if the data in the two colums is unrelated then two tables is the way to go, however if the value in “Field 2” is filtered and set from “Field 1” table entry then a single table will do or a second table with Key1, Key2.