@Normal@<+!><:f720,BHelvetica,0,0,0><:f900,2CG Times (WN),0,0,0><:f900,2CG Times (WN),0,0,0><+!><:f720,BHelvetica,0,0,0>Approach Tech Notes
@Normal@<+!><:f200,6Times New Roman,0,0,0>Approach 2.0 for Windows<:f160,BHelveticaNeue MediumCond,0,0,0> TN 4/93-1004<:f320,BHelveticaNeue MediumCond,0,0,0>
@Normal@<+!><:f280,BHelvetica,0,0,0>Cascading Deletes with Approach for Windows<-!><:f>
<:f900,2CG Times (WN),0,0,0><+!><:f720,BHelvetica,0,0,0><-!><:f><+!><:f280,BHelvetica,0,0,0>
@Normal@<:#293,4200><+!><:f280,BHelvetica,0,0,0><-!><:f><+!><:f280,2CG Times (WN),0,0,0><-!><:f><+!><:f280,2CG Times (WN),0,0,0><-!><:f><+!><:f240,BHelvetica,0,0,0><-!><+!>Objective<-!><:f240,6Times New Roman,0,0,0>
@Normal@<:#2112,4200><:f220,6Times New Roman,0,0,0>Automate the deletion of records in joined databases. Delete the main or parent record and instruct Approach to automatically delete all of the related detail or child records. This avoids "orphaned" records in the detail or c
hild database. If the join is several levels deep, instruct Approach to automatically delete detail or child records throughout the several levels.
@Normal@<:#144,4200><:f120,6Times New Roman,0,0,0>
@Normal@<:#293,4200><+!><:f240,BHelvetica,0,0,0>Example<-!><:f240,6Times New Roman,0,0,0>
@Normal@<:#2112,4200><:f220,6Times New Roman,0,0,0>The main database, CUSTOMER, contains fields for customer address, phone number, etc. The detail or child database, INVOICES, contains the individual invoices for each customer. The CUSTOMER database and the INVOICE database
are joined on a common CUST_ID code in a one-to-many relationship (one customer can have many invoices).
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@Normal@<:#792,4200><:f220,6Times New Roman,0,0,0>To set up Approach so that deleting a CUSTOMER record deletes all related records in INVOICES:
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@list@<:#528,4200>1. From the CUSTOMER view file, enter the Design mode.
@list@<:#264,4200>2. From the File Menu, select Join.
@list@<:#1848,4200>3. The main database, CUSTOMER in this example, should be the left-most database in the Join Dialog box. If not, return to Design mode and create a new form by adding fields from the CUSTOMER or main database only. Then repeat steps one through three.
@list@<:#1320,4200>4. Click the line that connects CUSTOMER, the main database, to INVOICE, the detail database. Once clicked, this line will darken or become bold.
@list@<:#528,4200>5. Click the Options button at the lower right of the Join Dialog box.
@list@<:#528,4200>6. Place a check in front of the second option:
@list@<:#792,4200> "Delete: Deleting a record in CUSTOMER deletes matching records in INVOICE."
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@list@<:#1320,4200> This option specifies that when a record in the main database is deleted all corresponding records in the detail database will also be deleted. If the two "Insert Options" are checked, leave them that way.
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@list@<:#1320,4200>7. You may want to select Refresh from the Records menu after deleting a record from the main database to ensure that any and all deletions are updated in the destination file(s).
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@list@<:#1848,4200> If the join is several levels deep and you want a single delete of a main record to delete corresponding detail records through out the levels, you must define this cascading relationship for each of the connecting databases. Repeat steps 1 through 6 for
each of these databases.
@Normal@<:#264,4200><:f220,6Times New Roman,0,0,0>
@Normal@<:#264,4200><+"><:f220,6Times New Roman,0,0,0>