The first example updates a Text control with the address for a name chosen from a ComboBox control. The field that is dataLinked to the ComboBox control has a lookupSQL property, so the lookup rowset is automatically generated. The address is retrieved through the lookupRowset property. This is the field’s onChange event handler.

function name_onChange

   local f,r // Variables for the form and lookupRowset 

   f = this.parent.parent.parent.parent // Form is 4 parents up 

   r = this.lookupRowset.dataLink 

   if r.endOfSet // No match 

      f.address.text := "" // Blank text 

   else 

      f.address.text := r.fields[ "Address" ].value + "<BR>" + ; 

      r.fields[ "City" ].value + " " + ; 

      r.fields[ "State" ].value + " " + ; 

      r.fields[ "Zip" ].value 

   endif 

Whenever the value in the ComboBox control changes, a lookup is performed, moving the row cursor in the lookup rowset. Wherever it is, you can retrieve the values for any other field in that row, as long as you include those fields in the SQL SELECT statement.

The second example assigns an existing rowset, opened earlier in the instantiation of the form, to two fields in the rowset in the query’s onOpen event.

function inspection1_onOpen

this.rowset.fields[ "Primary" ].lookupRowset := this.parent.inspector1.rowset 

this.rowset.fields[ "Backup" ].lookupRowset := this.parent.inspector1.rowset