Display field (B) value, based on multi-select box selection of field (A)

  • 0
  • 1
  • Question
  • Updated 6 years ago
  • Answered
My table contains two fields:

[Name] ("Multiple-choice from another field" field type)
[Abbreviation] ("Text" field type)

I'm adding a new record in another table that references [Name] for selection into a field.

When [Name] is selected within the form for the new record, I would like the associated [Abbreviation] displayed in a read-only text field so it can't be changed.

I know this can be done, but how?
Photo of David W. Brown

David W. Brown

  • 0 Points

Posted 6 years ago

  • 0
  • 1
Photo of KenFirch

KenFirch

  • 10 Points
How is [Name] "associated" with an [Abbreviation] ?
Photo of David

David

  • 0 Points
Hey there, did you find an answer to this?
Photo of David

David

  • 0 Points
Looking for a similar solution - basically a vlookup from another table based on the value in "multiple choice from another field" dropdown
Photo of Ken

Ken

  • 200 Points 100 badge 2x thumb
Could use Dan's Image Onload technique to populate other field(s) based on looking up a value, with no relationship between the tables.
Example, if you have a zip code table and want to populate the city and state fields after editing the zip code field in customer table, you could have an Onload.js on the customer form something like the following.   Probably could be written to more efficient....

(function(){

  function DoZipLookup(){
    // Use to lookup City/State if Zip Code field changes.
    // Customer table FieldIDs: Zip - 10, City - 8, State - 9.    
    // Zip table FieldIDs: Zip - 6, City - 7, State - 8.
     $("input[name=_fid_10]").blur(function() {
        var lookuptable = "bhwnnzips";
        var apptoken = "apptoken6i5xqc6uqm3happtoken";
        // Store value to be looked up.
        var lookupval = $("input[name=_fid_10]").val().trim();
        // If lookupval is not blank then perform lookup.
        if(lookupval != "") {
          var url = lookuptable  + "?act=API_DoQuery&query=({'6'.EX.'" + lookupval + "'})&clist=7.8&apptoken=" + apptoken;
          $.get(url,function(xml){
            var city = $("city",xml).text();
            var state = $("state",xml).text();
            if(city.trim() != "") {
              $("input[name=_fid_8]").val(city);   
              $("input[name=_fid_9]").val(state);   
           }else{
              $("input[name=_fid_8]").val("???");   
              $("input[name=_fid_9]").val("??");   
            }
          });
        }else{
          $("input[name=_fid_8]").val("???");   
          $("input[name=_fid_9]").val("??");   
        }
     });   
  }

// Use this image onload method to aid data entry.   
 var querystring=document.location.search;

 if (/dlta=mog/.test(querystring)) {
  //GRID EDIT PAGE ========================================
  // alert("You are on the Grid Edit Page");

 } else if(/a=er/.test(querystring)) {
  //EDIT RECORD PAGE ========================================
  // alert("You are on the Edit Record Page");
  DoZipLookup();

 } else if (/a=nwr/.test(querystring)) {
  //ADD RECORD PAGE ========================================
  // alert("You are on the Add Record Page");
  DoZipLookup();

 } else if(/a=dr/.test(querystring)) {
  //DISPLAY RECORD PAGE
  //$("img[qbu=module]").closest("td").css("background-color","#FFFFFF");
  // alert("You are on the Display Record Page");

 } else if(/a=q/.test(querystring)) {
  //REPORT PAGE ========================================
  //alert("You are on the Report Listing Page");

 } else {
  //OTHER PAGE ========================================
  //alert("You are on the Some Other Page");
 }

})();

Ken (aka 6s524 since this site can't seem to forget the last signon id even after deleting cookies....)
Photo of Trinity_QB_Ninja

Trinity_QB_Ninja, Champion

  • 40 Points
Abandon the "Multi-choice from another field". Create a another table to hold the Name and Abbrev Name. Make the key field of this new table "Name". Then create a relationship between the new table and the existing one with the new table as the parent. When creating this table, on the third screen you can select the existing "Name" field in the existing table to be the reference field. This will connect all of the existing records. Add the Abbrev Name field as a look up field. This will allow you to show the field and it will be un-editable.