Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error Message
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00507781
Message ID:
00507799
Vues:
11
>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
&& At this point xErrorCode == .F.
ON ERROR xErrorCode = ERROR()

DELETE FROM CUSTOMER WHERE customerID == customerID_you_want_to_delete

IF (TYPE("xErrorCode")!="L") && Since xErrorCode is not LOGICAL anymore, an error occured

DO CASE

&& Inside the case, depending on the error code, you´ll do something!

ENDCASE

ENDIF
Hope this helps to solve your problem!

Alonso
Like Frank said: "I did it... MY WAY!"
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform