delete record  
Author Message
honey1016





PostPosted: Visual FoxPro General, delete record Top

when you are in data entry screen and i want to delete the record. In parent table i already delete the record but in child table i was'nt able to delete. help me. thanks


Visual FoxPro2  
 
 
Aleniko





PostPosted: Visual FoxPro General, delete record Top

You need to give us more information. How are you trying to delete the record What happens
If you're issuing a delete command, make sure you're on the correct record. Or you may want to use a rule in the database container to delete child records when parent record is deleted (Cascade).



 
 
Lakshmi N





PostPosted: Visual FoxPro General, delete record Top

Sir,

if u are very new (like me) to advanced visual foxpro programming and dont know how to use triggers, constraints and all and if ur table structures are like this then u can try this.

master table

order no orderdate itemcode soldqty

tran table

order no itemcode itemname soldqty

and for every one order in your master there are multiple items sold and records exist in tran table

then code to be executed when delete push button is clicked

  1. sele a
  2. use master
  3. set orde to orderno
  4. seek m.orderno &&orderno that u want to delete, pls store it in a variable
  5. delete
  6. sele b
  7. use tran
  8. set orde to orderno
  9. delete for orderno = m.orderno &&orderno that u want to delete, pls store it in a variable

i think this is very primitive method of doing,

i think u can set relation and may be have some constraint (key field) and all. so with that u define primay key, when u delete from master table, it will delete all the matching records from tran table also.

i think in vfp help this info is avilable, since i am using foxpro for windows, we normally write code to delete matching records.

thanks and regards

(Lakshminarayana R)



 
 
Docpro777





PostPosted: Visual FoxPro General, delete record Top

Lakshmi's routine seems OK; mine is similar to his for deleting (indexed) child records ... (I've had sad times with delete cascade-triggers in RI)

You'd probably place the routine like his in your "delete" procedure, function, or method of that parent form.