I have invoice header (tbl_stk_hdr_vdn) and invoice detail (tbl_stk_dtl_vdn) and I have created the set which invoice header to invoice detail (one to many relationship), call set_vdn.
I have created a form using the set of "set_vdn". I created 2 tab page, first tab page show all the header information and 2nd tab page is the browse of detail information. everything is ok.
i have created a button on the 2nd tab page for user to click to add new record for the detail and a new form show (using the tbl_stk_dtl_vdn). After user enter the information for the detail and save the record, the browse on the tab2 refresh. Tab2 on the browse, user just double click the row and the detail form show for user to update the record.
The problem is that, when the user want to delete the record, the pc hug every long and at the end alpha prompt the message:
tbl.change_being()
the proces cannot access the file because another process has locked a portion of the file. tbl_stk_dtl_vdn.
my code for delete is:
dim tbl as p
dim qry as p
dim count as n
tbl = table.open("tbl_stk_dtl_vdn",FILE_RW_SHARED)
query.filter = "Std_id = " + str(vn_pk_id) 'Primary Key
qry = tbl.query_create()
count = qry.records_get()
If count = 1 then
tbl.change_begin()
tbl.delete()
tbl.change_end()
end if
qry.close()
tbl.close()
'Close the form
parentform.close(.f.)
however, If I use the action script "Delete Function", it can delete the detail record without prompt any error.
Now the Form using set_vdn, and the detail entry form using tbl_stk_dtl_vdn, it that is the problem?
Please help.. how to delete the record using the above script.
I have created a form using the set of "set_vdn". I created 2 tab page, first tab page show all the header information and 2nd tab page is the browse of detail information. everything is ok.
i have created a button on the 2nd tab page for user to click to add new record for the detail and a new form show (using the tbl_stk_dtl_vdn). After user enter the information for the detail and save the record, the browse on the tab2 refresh. Tab2 on the browse, user just double click the row and the detail form show for user to update the record.
The problem is that, when the user want to delete the record, the pc hug every long and at the end alpha prompt the message:
tbl.change_being()
the proces cannot access the file because another process has locked a portion of the file. tbl_stk_dtl_vdn.
my code for delete is:
dim tbl as p
dim qry as p
dim count as n
tbl = table.open("tbl_stk_dtl_vdn",FILE_RW_SHARED)
query.filter = "Std_id = " + str(vn_pk_id) 'Primary Key
qry = tbl.query_create()
count = qry.records_get()
If count = 1 then
tbl.change_begin()
tbl.delete()
tbl.change_end()
end if
qry.close()
tbl.close()
'Close the form
parentform.close(.f.)
however, If I use the action script "Delete Function", it can delete the detail record without prompt any error.
Now the Form using set_vdn, and the detail entry form using tbl_stk_dtl_vdn, it that is the problem?
Please help.. how to delete the record using the above script.
Comment