#Define FOXYCLASSESPATH "d:\FoxyClasses" If ! ( FOXYCLASSESPATH + "\CLASSES\GRIDS.VCX" $ Set('Classlib') ) Set Classlib To ; (FOXYCLASSESPATH + "\Classes\Grids.vcx") Additive Endif oForm = Createobject('myForm') oForm.Show Read Events Define Class myForm As Form DataSession = 2 Top = 0 Left = 0 Height = 469 Width = 786 DoCreate = .T. Caption = "Form1" Name = "Form1" Add Object editgrid1 As editgrid With ; Height = 252, ; Left = 24, ; RecordSource = "orders", ; Top = 192, ; Width = 648, ; ckeyfield = "cust_id", ; ckeyexpression = "customer.cust_id", ; Name = "Editgrid1" Add Object locatorgrid1 As locatorgrid With ; Height = 156, ; Left = 24, ; Top = 12, ; Width = 648, ; csql = "cust_id,company,contact from customer", ; followfield = "cust_id", ; followtable = "customer", ; followtag = "cust_id", ; Name = "Locatorgrid1" Add Object command1 As CommandButton With ; Top = 384, ; Left = 684, ; Height = 27, ; Width = 84, ; Caption = "Add", ; Name = "Command1" Procedure Init With This.editgrid1 .ChildOrder = 'cust_id' .LinkMaster = .RecordSource .RelationalExpr = 'cust_id' Endwith Endproc Procedure command1.Click Insert Into Orders (cust_id) Values (customer.cust_id) Thisform.editgrid1.SetFocus() Endproc Procedure editgrid1.When If !Seek(customer.cust_id,'orders','cust_id') Insert Into Orders (cust_id) Values (customer.cust_id) Endif Endproc Procedure Load Use customer In 0 Use Orders In 0 Endproc Procedure QueryUnload Clear Events Endproc EnddefineCetin