saving a record with multiple subforms

saving a record with multiple subforms

Postby mlawton » Tue Nov 15, 2016 8:09 am

I have a form with several subforms, each of which refer to the same product detail table (but with different fields from that table, for ease of viewing and editing). The key id that differentiates each record in the subforms can only be updated, added, and deleted in one of the subforms - the other subforms display it but read-only. Everything works except when I go to save a change I have made to a record in one of the subforms. I get the message: "There is already a record with a Period with a values of 562a5432a2a93fa in subform Add or delete periods on row 1.. (TAB : Details). I get this same message for each row in the subform. Period is the key id field for each row, and the value in the error message is the Period id value for that row. "Add or delete periods" is the title of the subform in which the user can add or delete records - all the other subforms cannot add or delete records, only update them.

I thought I had this working successfully awhile ago, but now I consistently run into this problem. I was sure I could have multiple subforms referring to the same underlying table in a form, but with this problem I am not so sure anymore. Any advice?
mlawton
 
Posts: 16
Joined: Tue May 10, 2016 1:46 am

Re: saving a record with multiple subforms

Postby admin » Tue Nov 15, 2016 1:20 pm

mlawton,

Sounds like you have put the primary key as an object in the subform, try taking it out.

Steven
admin
Site Admin
 
Posts: 3211
Joined: Mon Jun 15, 2009 9:53 am

Re: saving a record with multiple subforms

Postby mlawton » Thu Nov 17, 2016 3:44 am

The primary key of the table for the subform is not displayed anywhere. "period_id" is a foreign key in the subform table. I display it as a lookup field in each of the subforms so that the user can identify the rows in each subform. For all but one subform I make this field readonly, and I turn off the ability to add or delete rows. In one subform I make it read/write and turn on the ability to add or delete rows. But no matter what I tweak in the subforms I still get the error message outlined above. When I update a field in any of the subforms, it seems like nubuilder code behind the scenes is trying to add new rows using the existing rows' period_ids.
mlawton
 
Posts: 16
Joined: Tue May 10, 2016 1:46 am

Re: saving a record with multiple subforms

Postby mlawton » Sun Nov 20, 2016 12:41 am

FYI, after a lot of trial and error, I isolated the issue to one of the subforms, then deleted it and recreated a new subform with the same specifications, and it now works. I no longer receive the sql errors mentioned above. I don't know why, but at least it is working now.
mlawton
 
Posts: 16
Joined: Tue May 10, 2016 1:46 am

Re: saving a record with multiple subforms

Postby admin » Wed Jan 25, 2017 12:34 pm

Thats good news
admin
Site Admin
 
Posts: 3211
Joined: Mon Jun 15, 2009 9:53 am


Return to General