Need a code help for beginner

slmaluwaslmaluwa Member Posts: 366
Hi
I am learning NAV with the help of manuals. With the current level of my knowledge, I cannot figure out how to do the following in C/AL:

I need a simple form to display one field based on the value of another.

Table1: CONTINENTS
CON_CODE DESC
Asia Asia
Aus Australia
Amer America

Table2: COUNTRIES
CON_CODE CountryCode Name
Asia IND India
Asia MV Maldive
Ame US USA
Aus AU Australia

Two fileds in the form: Continent and Country

Need to do:
List the continents in a list box style in field1
When the user try to select the country, based the value in the field1, show the list and let him select one.

Can you guys show me a tutorial for this kind of excercise, please?

Thanks
"A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."

Comments

  • PeterDPeterD Member Posts: 66
    Use the field property TableRelation.


    Table 3: The one you need the continent and country info in.

    Add field Continent with Tablerelation:
    Continents

    Add field Country with Tablerelation:
    Country WHERE (CON_CODE=FIELD(Continent)


    You get what you want when you put those fields on a form.
  • slmaluwaslmaluwa Member Posts: 366
    Thanks for the reply.

    But, are you suggesting to create a THIRD table? The relationship between the two tables already created.
    Can you please rewrite your help text using the names below?

    TextBox1: varContinent
    TextBox2: varCountry

    Table1: Continent (CONTINENT_CODE,CONTINENT_NAME)
    Table2: Country (CONTINENT_CODE,COUNTRY_CODE,COUNTRY_NAME)

    Form: No source Table added. Just a plain form

    Thank you again

    Bodhi
    "A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."
  • DenSterDenSter Member Posts: 8,305
    1: create a list form for the CONTINENTS table. Note the form number.
    2: set the LookupFormID of the CONTINENTS table to that new form
    3: set the TableRelation property of your COUNTRIES table to CONTINENTS
    4: create a list form for your COUNTRIES table

    When you open the new COUNTRIES list form, and you put your cursor in the CONTINENT_CODE field, the list form for CONTINENTS should automatically pop up, and when you click OK it should automatically fill in the continent code.
Sign In or Register to comment.