Creating a field that checks values in another table
In this tutorial, we will see how use a field with type “Select” to checks values that are in another tables. For example, we are using two tables:
states”(that will include the values to be checked) and “
city” (that will receive the values that are in states).
First we will see how is organized the table that we will use to receive the information
see image that are below:
Try see that we have two fields, that have a relation of “Value x description”. The field stateid have the acronyms each state, the field statename have the description each state.
Now we will see the form that was created in table “City”, see image that are below:
How can see above, the table “City” have only two fields, Cityname and Stateid, where the field stateid will be the field used to receive the values that are in table “States”, with this way we can restrict the insert only states registered.
So, we will change the type of the data of the field Stateid to “select”, accessing the left menu “Field -> Stateid”.
And for finish, it's only create a SQL Select Statement in option “Lookup Settings”, in this example we are using the option Lookup Method “Automatic”, where the field Stateid will the value to be insert in the database when the rows will be choose, and the field StateName will used only how description. Below have theStatement generate that was used for this tutorial:
To finish this process you will have a field with the type select that will show the values of the field description of the table “States”, and will insert in the table “City” the value select of the field stateid.