PRB: Trigger Fails with One-to-Many Form Wizard and RI BuilderID: Q137278 The information in this article applies to:
SYMPTOMSThe following sequence of events results in this error:
Sequence of Events Leading to Error1. Use the Referential Integrity (RI) Builder to set the Insert Trigger of 2. Use the One-to-Many Form Wizard to create a form.
3. Run the form, and click Add, then click Add Record to Both in the Add
CAUSEWhen Visual FoxPro opens the tables, it opens the parent first and then the child. The Parent table is opened in work area one. When the child table is opened, the parent is moved to work area two, and the child is opened in work area one. The UpdateRows method in Wizstyle.vcx handles updating the tables. It uses the AUSED() function to place the names of the tables into an array and a For loop to cycle through each table and append the new record. Because the record is appended to the child table first (because of its order in the array and work area), the trigger cannot find a matching record in the parent, so it fails. If the the record was appended to the parent table first, the problem would not occur.
RESOLUTIONYou can modify the code in the UpdateRows method of the txtbtns class of Wizstyle.vcx. Find the line that reads:
Change it to this:
This causes the record to be appended to the parent table first, so the
Insert trigger will see a corresponding record in the parent when it
updates the child.
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior1. Create a database called test, and add two tables (a parent and a child, 2. Set the index on the parent table to Primary, and the index on the child
3. Start the Referential Integrity Builder. Change the Insert rule to
4. Start the One-to-Many Form Wizard, and follow these steps:
5. When the form is running Click Add. The click Add Record to Both in the
6. Type a value in the Key Value text box.
7. Click Add, and then click Save. At this point, the error occurs:
8. Change the line of code as previously described, and rerun the form.
Additional reference words: 3.00 VFoxWin
KBCategory: kbtool kbprb
KBSubcategory: FxtoolWizscreen
|
Last Reviewed: September 29, 1995 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |