mform = CREATEOBJECT("MyMainForm") mform.Show() READ EVENTS DEFINE CLASS MyMainForm AS form DataSession = 2 Top = 0 Left = 0 Height = 250 Width = 372 DoCreate = .T. Caption = "Form1" KeyPreview = .T. Name = "Form1" ADD OBJECT grid1 AS grid WITH ; Height = 200, ; Left = 9, ; Top = 44, ; Width = 320, ; Name = "Grid1" PROCEDURE Init CREATE CURSOR TestFile (Field1 C(10), Field2 C(10)) thisform.Grid1.RecordSource = "TestFile" thisform.Grid1.Refresh() ENDPROC PROCEDURE KeyPress LPARAMETERS nKeyCode, nShiftAltCtrl LOCAL pForm IF nKeyCode == 13 NODEFAULT ** DO FORM ParentF WITH (nShiftAltCtrl==1) && Shift+Enter -> APPEND Record, Otherwise EDIT record pForm = CREATEOBJECT("MyParentForm",(nShiftAltCtrl==1)) pForm.Show(1) thisform.Grid1.Refresh() RETURN ENDIF IF nKeyCode == 27 && Esc NODEFAULT thisform.Release() RETURN ENDIF ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC ENDDEFINE DEFINE CLASS MyParentForm AS form Top = 0 Left = 0 Height = 124 Width = 294 DoCreate = .T. Caption = "Form1" WindowType = 1 Name = "Form1" is_append = .F. ADD OBJECT text1 AS textbox WITH ; Height = 23, ; Left = 34, ; Top = 30, ; Width = 100, ; Name = "Text1" ADD OBJECT text2 AS textbox WITH ; Height = 23, ; Left = 149, ; Top = 30, ; Width = 100, ; Name = "Text2" ADD OBJECT command1 AS commandbutton WITH ; Top = 80, ; Left = 55, ; Height = 27, ; Width = 84, ; Caption = "Save", ; Name = "Command1" ADD OBJECT command2 AS commandbutton WITH ; Top = 80, ; Left = 154, ; Height = 27, ; Width = 84, ; Caption = "Cancel", ; Name = "Command2" PROCEDURE Init LPARAMETERS is_append thisform.is_append = (is_append .OR. RECCOUNT("TestFile") == 0) IF thisform.is_append thisform.Text1.Value = SPACE(10) thisform.Text2.Value = SPACE(10) ELSE thisform.Text1.Value = TestFile.Field1 thisform.Text2.Value = TestFile.Field1 ENDIF thisform.Text1.refresh() thisform.Text2.refresh() thisform.Text1.SetFocus() ENDPROC PROCEDURE command1.Click IF thisform.is_append INSERT INTO TestFile (Field1, Field2) VALUES; (thisform.text1.Value, thisform.Text2.Value) ELSE REPLACE Field1 WITH thisform.text1.Value,; Field2 WITH thisform.Text2.Value IN TestFile ENDIF thisform.Release() ENDPROC PROCEDURE command2.Click thisform.Release() ENDPROC ENDDEFINE