Welcome to the nuBuilder forums!

Please register and login to view forums and other content only available to registered users.

saving a record with multiple subforms

Post Reply
mlawton
Posts: 16
Joined: Mon May 09, 2016 6:16 pm

saving a record with multiple subforms

Unread post by mlawton »

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?
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: saving a record with multiple subforms

Unread post by admin »

mlawton,

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

Steven
mlawton
Posts: 16
Joined: Mon May 09, 2016 6:16 pm

Re: saving a record with multiple subforms

Unread post by mlawton »

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: Mon May 09, 2016 6:16 pm

Re: saving a record with multiple subforms

Unread post by mlawton »

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.
admin
Site Admin
Posts: 2781
Joined: Mon Jun 15, 2009 2:23 am
nuBuilder Version: 4.5
Been thanked: 1 time

Re: saving a record with multiple subforms

Unread post by admin »

Thats good news
Post Reply