Glad forum questions are still being submitted for A5V11!
I have a set defined with two tables (Table1 and Table2; linked as "One to Many" to Table1). I've created two forms for these tables based upon the set definition; Form1 to update Table1 and Form2 to update Table2. A button on Form1 opens Form2 and it does indeed display records from Table2 as designed. My problem is with buttons on Form2 to Add, Change, Cancel, Save and Delete records in Table2. I initially used pre-defined buttons for these actions. Why not? Should be simple, no? No. The Change, Cancel and Save buttons work fine on the record displayed in Form2; however, the Add and Delete buttons work on the displayed record in Form1. Definitely NOT my intention! I was quite surprised when I confirmed "Delete Record" in Form2 (thinking it was the Table2 record displayed on Form2) and I lost not only the two records in Table2 associated with the record in Table1, but the Table1 record as well. Turns out I was confirming deleting the Table1 record and, of course, the two records in Table2 were also deleted because of the referential integrity of the tables.
I placed some UI Message Boxes in the various buttons on Form2 and displayed a value using a field name common to both tables (FIRST_NAME) to see what gives.
p = parentform.this
tp = topparent.this
Both "p.FIRST_NAME" and tp.FIRST_NAME displayed the value on Form2 from Table2. Displaying the current record number however, shows the record number of the record in Table1; which, I'm guessing, explains why the Add and Delete buttons don't work on Table2. They're referencing the record in Table1.
I suppose someone is going to tell me I have to add records to Table2 from an embedded browse in Form1 (rather than opening a new form for that purpose); however, I AM wondering why, from Form2 "topparent.allow_change()" and "topparent.commit()" work on Table2 but "topparent.new_record()" and "topparent.delete_record()" apply to Table1?
I have a set defined with two tables (Table1 and Table2; linked as "One to Many" to Table1). I've created two forms for these tables based upon the set definition; Form1 to update Table1 and Form2 to update Table2. A button on Form1 opens Form2 and it does indeed display records from Table2 as designed. My problem is with buttons on Form2 to Add, Change, Cancel, Save and Delete records in Table2. I initially used pre-defined buttons for these actions. Why not? Should be simple, no? No. The Change, Cancel and Save buttons work fine on the record displayed in Form2; however, the Add and Delete buttons work on the displayed record in Form1. Definitely NOT my intention! I was quite surprised when I confirmed "Delete Record" in Form2 (thinking it was the Table2 record displayed on Form2) and I lost not only the two records in Table2 associated with the record in Table1, but the Table1 record as well. Turns out I was confirming deleting the Table1 record and, of course, the two records in Table2 were also deleted because of the referential integrity of the tables.
I placed some UI Message Boxes in the various buttons on Form2 and displayed a value using a field name common to both tables (FIRST_NAME) to see what gives.
p = parentform.this
tp = topparent.this
Both "p.FIRST_NAME" and tp.FIRST_NAME displayed the value on Form2 from Table2. Displaying the current record number however, shows the record number of the record in Table1; which, I'm guessing, explains why the Add and Delete buttons don't work on Table2. They're referencing the record in Table1.
I suppose someone is going to tell me I have to add records to Table2 from an embedded browse in Form1 (rather than opening a new form for that purpose); however, I AM wondering why, from Form2 "topparent.allow_change()" and "topparent.commit()" work on Table2 but "topparent.new_record()" and "topparent.delete_record()" apply to Table1?
Comment