d = new database() d.databaseName = "dbasesamples" d.active = true tDef = new tableDef() tDef.database := d tDef.tableName := "customers" tDef.load() for n = 1 to tdef.indexes.size // cIndex = tDef.indexes[n].indexname // ?cindex if upper(tDef.indexes[n].indexname) = 'COMPANY_LOWER' cSafety = set('safety') set safety off use :dbasesamples:customers exclusive index on lower(company) tag company_lower use set safety &cSafety n = tdef.indexes.size //Abort loop endif next d.active = false ** END HEADER -- do not remove this line // // Generated on 2023-06-02 // parameter bModal local f f = new Main_formForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class Main_formForm of FORM with (this) canClose = class::FORM_ONCLOSE onOpen = class::FORM_ONOPEN height = 20.0 left = 2.0 top = 0.0 width = 100.0 text = "" endwith this.DBASESAMPLES1 = new DATABASE(this) with (this.DBASESAMPLES1) left = 13.0 width = 11.0 height = 1.0 databaseName = "DBASESAMPLES" active = true endwith this.CUSTOMERS1 = new QUERY(this) with (this.CUSTOMERS1) left = 6.0 width = 9.0 height = 1.0 database = form.dbasesamples1 sql = "select * from CUSTOMERS.DBF" active = true endwith this.GRID1 = new GRID(this) with (this.GRID1) dataLink = form.customers1.rowset height = 9.5455 left = 7.7143 top = 2.1364 width = 82.5714 endwith this.ENTRYFIELD1 = new ENTRYFIELD(this) with (this.ENTRYFIELD1) onKey = class::ENTRYFIELD1_ONKEY height = 1.0 left = 27.2857 top = 17.7273 width = 19.4286 value = "" endwith this.TEXT1 = new TEXT(this) with (this.TEXT1) height = 4.4545 left = 23.7143 top = 12.0909 width = 36.0 text = "Enter Customer ID (max 101) or

Company name. (Not case-sensitive).

Left-click pushbutton or press either Enter or Tab to open Edit form for the selected record." endwith this.PUSHBUTTON1 = new PUSHBUTTON(this) with (this.PUSHBUTTON1) onClick = class::PUSHBUTTON1_ONCLICK height = 1.7273 left = 60.1429 top = 17.3182 width = 15.2857 text = "Edit selected record" endwith this.rowset = this.customers1.rowset function ENTRYFIELD1_onKey(nChar, nPosition,bShift,bControl) local cVal if len(this.value) <> 0 //Avoid error if entryfield is cleared //If Enter or Tab press, execute the function pb_goto_onClick if nChar = 13 or nChar = 9 form.pushbutton1_onClick() endif //Check first character and set appropriate index if nPosition = 2 and not isAlpha(this.value) form.CUSTOMERS1.rowset.indexname = 'CustomerID' endif if nPosition = 2 and isAlpha(this.value) form.CUSTOMERS1.rowset.indexname = 'company_lower' endif //Change rowpointer //findKey() requires a variable, not an object property, //as its argument hence the use of cVal instead of this.value if isAlpha(this.value) cVal = trim(this.value) form.CUSTOMERS1.rowset.findkey(cVal) else cVal = val(this.value) form.CUSTOMERS1.rowset.findkey(cVal) endif endif return function PUSHBUTTON1_onClick() form.edit_form = new edit_formForm() //Create instance of edit_form in memory. form.edit_form.parent = form // Open path back to form from edit_form to facilitate requery(). nCustID = form.customers1.rowset.fields['customerID'].value //Save the customerID value form.edit_form.customers1.rowset.findkey(nCustId) //Move the rowpointer to the correct record in the edit form form.edit_form.mdi = false form.edit_form.readModal() return function form_onClose() form.customers1.active = false form.dbasesamples1.active = false return true function form_onOpen() set procedure to edit_form.wfm form.entryfield1.setFocus() return endclass