Table Relationship: Data Binding to Control

8816.untitled.JPG

Hello All,

I have a table which has two fields. On card page I want to show the values from table in drop down list ( as shown in figure).

For that I have given table relationship and I am able to see values in drop down list.

Now my requirement is that I need two drop dwon list on UI which will refere to same table but columns should be different.

Please Help!

In TableRelation property have you defined Table.Field1 & Table.Field2 for two different fields?

To specify which field the relationship refers to, set the table relation to Table.Field, e.g. Customer.Name or Customer.“Search Name”

If you omit the field, this defaults to the first field in the table, e.g. Customer is effectively the same as Customer.“No.”

This is explained in Chapter 7.2 of the Application Dev. Guide (w1w1adg.pdf) that comes with the Nav CD.

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”);

David

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.

New Field 1 OnValidate()

IF MyNewTable.GET(“New Field 1”)THEN BEGIN

“New Field 2” := MyNewTable. “New Field 2”;

“New Field 3” := MyNewTable. “New Field 3”;

“New Field 4” := MyNewTable. “New Field 4”;

END ELSE BEGIN

“New Field 2” := ‘’;

“New Field 3” := ‘’;

“New Field 4” := ‘’;

END;

David

Hello David, DhanRaj and Alastair,

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.

Please suggest some solution.

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.

David

Hi David,

For option 1 - The drop down list always shows keys selected for table, so for both DDL it shows same data.

I will try second option by adding another table for field2.

Regards.

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.

David

Hi David,

Filed 2 is not filtered based on Field 1. The two fields are not related. I just need to accept it as input on purchase invoice.

Regards.