MS-Access / Getting Started

Defining a Cascade Delete Relationship

There's one last relationship you need to define in the Restaurant Database between InvoiceDetails and InvoiceHeaders. The relationship between these two tables requires a Cascade Delete relationship. We want to ensure that when an invoice is deleted in the InvoiceHeaders web table (the one side of the relationship) that all corresponding child records in the InvoiceDetails web table (the many side of the relationship) are deleted.

Follow this procedure to build your Cascade Delete relationship:

  1. You want to include the InvoiceNumber field in the InvoiceDetails web table, so open the InvoiceDetails web table in Datasheet view and set the focus on the InvoiceDetailsID field. Start the Lookup Wizard by clicking More Fields and then clicking Lookup & Relationship.
  2. On the first page of the wizard, select the "The Lookup Field To Get The Values From Another Table" option, and then click Next.
  3. On the second page of the wizard, select the InvoiceHeaders web table, and then click Next.
  4. On the third page of the wizard, bring over the InvoiceNumber field from the Available Fields list to the Selected Fields list, and then click Next.
  5. On the fourth page of the wizard, select the InvoiceNumber field in the drop-down list to sort Ascending by that field, and then click Next.
  6. On the fifth page of the wizard, leave the default options as they are to hide the key column and keep the widths the same. Click Next to go to the final page of the wizard.
  7. On the last page of the wizard, shown here, name your field InvoiceID and select the Enable Data Integrity option. Select the Cascade Delete option, and then click Finish to complete the new field and relationship.

Out Viewing Web Relationships Limitation

One of the shortcomings of creating relationships in web databases is that you cannot view the Relationships window as you can in client databases. As a result, you cannot run the Relationships Report option to get a nice graphical printout of all the relationships in your web database.

[Previous] [Contents] [Next]