>I have table called customer, Customer have relationship with order table
>I want to delete record from customer master form, It not allow me to delete due to the relationship. it come out the system error message....
>Is that possible for me to handle those error message instead of system error message. I appreciate if you provide me the coding. Thanks!
Hi
Before deleting the data on customer table, you can search for any record in the other table (maybe a products table, right?) related to the customer you want to delete. If you find such records (using a SELECT - SQL or a SEEK), you tell the user he can´t delete the customer.
You can also trap the error. Before issuing the DELETE command, you use the ON ERROR statement assigning the error code to a variable, after the execution of the DELETE you test the value of the variable, if it has the error code, you tell the user he can´t delete the customer.
here´s a bit of code
1st Method (Using SEEK)
SELECT OTHER_TABLE
SET ORDER TO TAG cust_id
SEEK customerID_you_want_to_delete
IF (FOUND())
messagebox("The user has a relationship!")
RETURN
ELSE
DELETE FROM CUSTOMER WHERE customerID == customerID_you_want_to_delete
ENDIF
2nd Method (Error Traping
LOCAL xErrorCode
ON ERROR xErrorCode = ERROR()
DELETE FROM CUSTOMER WHERE customerID == customerID_you_want_to_delete
IF (TYPE("xErrorCode")!="L")
DO CASE
ENDCASE
ENDIF
Hope this helps to solve your problem!
Alonso
Like Frank said: "I did it... MY WAY!"