Populated drop-down not referring correctly

Populated drop-down not referring correctly

Oh no...!!! :-)

After some great help from members of this forum I finally thought I solved a problem that I have been struggeling with for some time. But now it turns out, it wasn't solved after all... I am hoping for some help to complete the last stretch to the finish line.

I have a drop-down with school-names which is populated using the ui.add function. The names come from the form "Organisation" and the name of the schools come from the row "Skolens_Navn" in that form. When selecting a school an add notes field appears underneath it displaying the address of the school. This comes from the row "Adresse". The reason for that is, that some schools can be spread accross different cities, therefore having different addresses.

I have now discovered, that when a school appears in the drop-down multiple times; no matter which one of these you select, the same address (the address of the first one) appears underneath. I am thinking this has to do with, that the drop-down when populated does not refer to the "ID" column of the "Organisation" form, where the name and address come from.

How can I make the right address appear underneath the drop-down? I have attached my code below.

Thank you in advance

J

---------

How the drop-down, "organisation" is populated

 
  1. clear Organisation;
    for each p in Organisation sort by Skolens_navn
    {
        if (p.Organisationstype  ==  input.Organisationstype)
        {
            Organisation:ui.add(p.Skolens_navn);
        }
    }






How the add notes field (adressetekst) is populated

 
  1.  get_address  =  Organisation  [Skolens_navn == input.Organisation];
        Adresse = get_address.Adresse;
  2. input.adressetekst = (("<font size=2><br><br><br>") + Adresse) + "</font>";