** END HEADER -- do not remove this line // // Generated on 2023-05-01 // parameter bModal local f f = new lookup_testForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class lookup_testForm of FORM with (this) onOpen = class::FORM_ONOPEN height = 21.5455 left = 27.1429 top = 0.0455 width = 60.2857 text = "" endwith this.STATES_LOOKUP1 = new QUERY(this) with (this.STATES_LOOKUP1) left = 36.0 width = 11.0 height = 1.0 sql = "select * from states_lookup.DBF where stateID = upper( :stateID)" params["stateID"] = "" active = true endwith this.ENTRYFIELD2 = new ENTRYFIELD(this) with (this.ENTRYFIELD2) when = {||false} height = 1.0 left = 24.0 top = 6.3636 width = 29.0 value = "" endwith this.TEXT1 = new TEXT(this) with (this.TEXT1) height = 0.7727 left = 3.1429 top = 4.9545 width = 14.5714 text = "Enter State ID " endwith this.ENTRYFIELD1 = new ENTRYFIELD(this) with (this.ENTRYFIELD1) onKey = class::ENTRYFIELD1_ONKEY height = 1.0 left = 4.4286 top = 6.4545 width = 8.0 value = "" endwith this.ENTRYFIELD3 = new ENTRYFIELD(this) with (this.ENTRYFIELD3) height = 1.0 left = 4.4286 top = 9.0455 width = 25.7143 value = "dummy to accept focus" endwith this.TEXT2 = new TEXT(this) with (this.TEXT2) height = 1.7273 left = 5.0 top = 11.1818 width = 48.4286 text = "Entering a valid two character stateID will look up the State name and dispay it in entryfield2." endwith this.TEXT3 = new TEXT(this) with (this.TEXT3) height = 1.5 left = 5.0 top = 13.2727 width = 48.1429 text = "Entryfield2 can never receive focus as its WHEN event handler has been set {||false}" endwith this.TEXT4 = new TEXT(this) with (this.TEXT4) height = 2.2727 left = 5.0 top = 16.1818 width = 48.1429 text = "A valid stateId will lookup the State name and display it in entryfield2. Focus will move to the next object in the z_order." endwith this.TEXT5 = new TEXT(this) with (this.TEXT5) height = 1.5 left = 5.0 top = 19.2273 width = 48.1429 text = "An invalid stateID will blank the entry in entryfield1 and wat for a new value." endwith this.TEXT6 = new TEXT(this) with (this.TEXT6) height = 1.5 left = 4.2857 top = 0.6818 width = 30.7143 text = "Mimic the DML LOOKUP() function in OODML" endwith function ENTRYFIELD1_OnKey(nChar, nPosition,bShift,bControl) if len(this.value) >1 // Two characters entered form.states_lookup1.params['stateID'] = this .value //pass value in entryfield to query parameter form.states_lookup1.requery() // fetch state name for the given stateID //Test to see if a valid stateID was entered if form.states_lookup1.rowset.count() = 1 //found the state form.entryfield2.value = form.states_lookup1.rowset.fields['state'].value this.before.setfocus() //Move focus to next object in z-order else // stateId not found form.entryfield2.value = 'Invalid StateID' form.entryfield1.value = '' //Empty entryfield form.entryfield1.setfocus() //Back to entryfield to try again endif endif return function form_onOpen() form.entryfield1.setfocus() return endclass