Hi,
I have a form base on the 1 to M SET, and simple as
Work_order(parent)
|
===== Schedule (M)
The Work_order has a field, "Foreman" and the Schedule is stored the Employee work schedule. It has WorkOrder_id and Emp_id fields.
I want to do, (1) created the employee schedule and
(2) create a drop down box within the schedule records
(3) Select one of the Emp_id from Schedule table,
(4) Change on the "Foreman" field on the Work_order table.
Problem is some reason, right after I added new employee schedule I am not able to change the parent records with this Button code.
It works after close the form and open again.
Does any one know why this code did not fire?
I have a form base on the 1 to M SET, and simple as
Work_order(parent)
|
===== Schedule (M)
The Work_order has a field, "Foreman" and the Schedule is stored the Employee work schedule. It has WorkOrder_id and Emp_id fields.
I want to do, (1) created the employee schedule and
(2) create a drop down box within the schedule records
(3) Select one of the Emp_id from Schedule table,
(4) Change on the "Foreman" field on the Work_order table.
Problem is some reason, right after I added new employee schedule I am not able to change the parent records with this Button code.
It works after close the form and open again.
Code:
'Save record in current form at parent level. topparent.commit() 'Find the records by current record number now and change later DIM vWrkOdrId AS c vWrkOdrId = parentform:wrkodr_id.value dim vForeman as c ="" 'Listing DIM vForeman_rl_def_orig as C vForeman_rl_def_orig = "k=wrkassign,{keylist_build(\"H=.05,1:30[Avail Foreman]\",''+Emp_id,left(''+lookup(\"emp\",\"emp_id=\"+quote(Emp_Id),\"Emp_fullname\"),30))}{(Wrkodr_id = [varc->vWrkOdrId] ) .and. unique_key_value()}" DIM vForeman_rl_def as C vForeman_rl_def = replace_parameters(vForeman_rl_def_orig,local_variables()) 'Create an XDialog dialog box to prompt for parameters. DIM varC_Foreman as C ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_Foreman = ui_dlg_box("Foreman",<<%dlg% {startup=init} {region} Foreman:| [%@vForeman_rl_def%.40vForeman]; {endregion}; {line=1,0}; {region} <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% If a_dlg_button = "init" then vWrkOdrId = replace_parameters(vWrkOdrId,local_variables()) vForeman_rl_def = replace_parameters(vForeman_rl_def_orig,local_variables()) a_dlg_button ="" end if %code%) 'Execute inline Xbasic code. if varC_Foreman ="cancel" then cancel() end end if If varC_Foreman="ok" then 'Open the table that want to update... dim tbl as p tbl = table.get("wrkodr_hd") 'test tbl = table.current(1) query.filter ="Wrkodr_id="+quote(vWrkOdrId) query.order="" qry = tbl.query_create() tbl.change_begin() tbl.FOREMAN = convert_type(vForeman,"Character") tbl.change_end(.t.) qry.drop() END IF 'Refresh data in current form at parent level. 'Can only resynch data in View mode, so save record first to be sure that layout is in View mode. topparent.Commit() topparent.Resynch() topparent.Refresh_Layout() end
Comment