Your finished code for form iiiMntDept should appear something like the following:
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_FORM) Clientwidth(484) Clientheight(217) Componentversion(2) Left(865) Top(215) Layoutmanager(#TableLayout1)
Define_Com Class(#PRIM_TBLO) Name(#TableLayout1)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column1) Displayposition(1) Parent(#TableLayout1) Width(1.53)
Define_Com Class(#PRIM_TBLO.Column) Name(#Column2) Displayposition(2) Parent(#TableLayout1) Width(0.47)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row1) Displayposition(1) Parent(#TableLayout1) Height(1.73)
Define_Com Class(#PRIM_TBLO.Row) Name(#Row2) Displayposition(2) Parent(#TableLayout1) Height(0.27)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem1) Alignment(TopLeft) Column(#Column1) Flow(Down) Manage(#DEPTMENT) Parent(#TableLayout1) Row(#Row1) Sizing(None) Margintop(10) Marginleft(20)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem2) Alignment(TopLeft) Column(#Column1) Flow(Down) Manage(#DEPTDESC) Parent(#TableLayout1) Row(#Row1) Sizing(None) Margintop(10) Marginleft(20)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem3) Column(#Column1) Manage(#StatusBar1) Parent(#TableLayout1) Row(#Row2) Columnspan(2)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem4) Alignment(BottomCenter) Column(#Column2) Flow(Up) Manage(#FETCH) Parent(#TableLayout1) Row(#Row1) Sizing(None) Marginbottom(10)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem5) Alignment(TopLeft) Column(#Column1) Flow(Down) Manage(#STD_NUM) Parent(#TableLayout1) Row(#Row1) Sizing(None) Margintop(10) Marginleft(20)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem6) Alignment(BottomCenter) Column(#Column2) Flow(Up) Manage(#INSERT) Parent(#TableLayout1) Row(#Row1) Sizing(None) Marginbottom(10)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem7) Alignment(BottomCenter) Column(#Column2) Flow(Up) Manage(#UPDATE) Parent(#TableLayout1) Row(#Row1) Sizing(None) Marginbottom(10)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem8) Alignment(BottomCenter) Column(#Column2) Flow(Up) Manage(#DELETE) Parent(#TableLayout1) Row(#Row1) Sizing(None) Marginbottom(10)
Define_Com Class(#PRIM_TBLO.Item) Name(#LayoutItem9) Alignment(BottomCenter) Column(#Column2) Flow(Up) Manage(#CLEAR) Parent(#TableLayout1) Row(#Row1) Sizing(None) Marginbottom(10)
Define_Com Class(#DEPTMENT.Visual) Name(#DEPTMENT) Displayposition(1) Parent(#COM_OWNER) Tabposition(1) Top(10) Left(20) Width(205)
Define_Com Class(#DEPTDESC.Visual) Name(#DEPTDESC) Displayposition(2) Parent(#COM_OWNER) Tabposition(2) Top(41) Left(20) Width(301)
Define_Com Class(#PRIM_STBR) Name(#StatusBar1) Autolayout(False) Displayposition(3) Height(29) Left(0) Messageposition(1) Parent(#COM_OWNER) Tabposition(6) Tabstop(False) Top(188) Width(484)
Define_Com Class(#PRIM_PHBN) Name(#FETCH) Displayposition(4) Left(387) Parent(#COM_OWNER) Tabposition(4) Top(153) Caption('Fetch')
Define_Com Class(#STD_NUM.Visual) Name(#STD_NUM) Componentversion(1) Displayposition(5) Height(21) Parent(#COM_OWNER) Tabposition(3) Top(72) Usepicklist(False) Width(229) Left(20)
Define_Com Class(#PRIM_PHBN) Name(#INSERT) Displayposition(6) Left(387) Parent(#COM_OWNER) Tabposition(5) Top(118) Caption('Insert')
Define_Com Class(#PRIM_PHBN) Name(#UPDATE) Displayposition(7) Left(387) Parent(#COM_OWNER) Tabposition(7) Top(83) Caption('Update')
Define_Com Class(#PRIM_PHBN) Name(#DELETE) Displayposition(8) Left(387) Parent(#COM_OWNER) Tabposition(8) Top(48) Caption('Delete')
Define_Com Class(#PRIM_PHBN) Name(#CLEAR) Caption('Clear') Displayposition(9) Left(387) Parent(#COM_OWNER) Tabposition(9) Top(13)
Group_By Name(#formdata) Fields(#DEPTMENT #DEPTDESC #STD_NUM)
Evtroutine Handling(#com_owner.CreateInstance)
Set Com(#com_owner) Caption(*component_desc)
Execute Subroutine(initFORM)
Endroutine
Evtroutine Handling(#FETCH.Click)
Fetch Fields(#formdata) From_File(deptab) With_Key(#DEPTMENT)
If_Status Is_Not(*okay)
Message Msgtxt('Error retrieving department record')
Else
#DEPTMENT.Enabled #FETCH.Enabled #INSERT.Enabled := False
#UPDATE.Enabled #DELETE.Enabled := True
Endif
Endroutine
Evtroutine Handling(#INSERT.Click)
Begincheck
Condcheck Field(#DEPTMENT) Cond(#DEPTMENT.Contains( ' ' )) If_True(*ERROR) If_False(*NEXT) Msgtxt('Code cannot contain embedded blanks.')
If Cond(#DEPTMENT *EQ #DEPTDESC)
Set_Error For_Field(#DEPTMENT #DEPTDESC) Msgtxt('Department Code cannot be the same as Department Description.')
Endif
Rangecheck Field(#STD_NUM) Range((1 10)) Msgtxt('Must be in range 1 to 10.')
Valuecheck Field(#DEPTDESC) With_List(NONE END LAST) In_List(*ERROR) Not_Inlist(*NEXT) Msgtxt('This description is reserved.')
Filecheck Field(#DEPTMENT) Using_File(DEPTAB) Using_Key(#DEPTMENT) Found(*ERROR) Not_Found(*NEXT) Msgtxt('Department Code already exists.')
Endcheck
Insert Fields(#formdata) To_File(deptab)
If_Status Is(*OKAY)
Message Msgtxt('Department inserted successfully')
Execute Subroutine(initFORM)
Else
If_Status Is(*ERROR)
Message Msgtxt('Error inserting Department')
Endif
Endif
Endroutine
Evtroutine Handling(#UPDATE.Click)
Update Fields(#formdata) In_File(DEPTAB) Val_Error(*NEXT)
If_Status Is(*OKAY)
Message Msgtxt('Department updated successfully')
Execute Subroutine(iniTFORM)
Else
If_Status Is(*NORECORD)
Message Msgtxt('Department not found')
Else
If_Status Is(*ERROR)
Message Msgtxt('Error updating Department')
Endif
Endif
Endif
Endroutine
Evtroutine Handling(#DELETE.Click)
Delete From_File(deptab)
If_Status Is(*OKAY)
Message Msgtxt('Department deleted successfully')
Execute Subroutine(initFORM)
Else
If_Status Is(*NORECORD)
Message Msgtxt('Department not found')
Else
If_Status Is(*ERROR)
Message Msgtxt('Error deleting Department')
Endif
Endif
Endif
Endroutine
Subroutine Name(INITFORM)
#formdata := *DEFAULT
#UPDATE.Enabled #DELETE.Enabled := False
#DEPTMENT.Enabled #FETCH.Enabled #INSERT.Enabled := True
Endroutine
Evtroutine Handling(#CLEAR.Click)
Execute Subroutine(iniTFORM)
Endroutine
End_Com