Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Grid subform can only add one record at a time

Questions related to using nuBuilder Forte.
Post Reply
Lala
Posts: 31
Joined: Thu Nov 07, 2024 11:46 pm
Has thanked: 8 times
Been thanked: 4 times

Grid subform can only add one record at a time

Unread post by Lala »

Hi
I have a Browse/Edit form called Household and a subform called Household Members. Primary key of Household is household_id which is joined to subform field household_id. The primary key of household members form is member_id.

I can open a household from the browse screen and it will show household members in a grid in the subform. So far, so good.
BUT
if I want to add more than one household member to the subform, it will only save the first record. Subsequent records are trying to use the same value for the member_id so the record isn't saved and the debug gives the message: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '675f3f78' for key 'PRIMARY' Why don't the new rows create new records?

Any help gratefully received!
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: Grid subform can only add one record at a time

Unread post by steven »

Hi Lala,

Can you show some screen shots, or even better, upload a copy of your database and we can have a look.

Steven
A short post is a good post.
Lala
Posts: 31
Joined: Thu Nov 07, 2024 11:46 pm
Has thanked: 8 times
Been thanked: 4 times

Re: Grid subform can only add one record at a time

Unread post by Lala »

I'm attaching a backup - I don't know if that's helpful or not. If not, speaking very slowly and clearly as though to a total dipstick, please let me know how to attach a copy of my database :roll:
12-16-2024_000444_675f7cac880f2_nuBuilder_backup.sql.gzip
You do not have the required permissions to view the files attached to this post.
steven
Posts: 369
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 52 times
Been thanked: 52 times

Re: Grid subform can only add one record at a time

Unread post by steven »

Hi Lala,

Thanks for sharing your database.

Firstly your app seems to try to call a function that doesn't exist...

no_function.png

The only other thing is that all Primary Keys and Foriegn Keys need to be 25 characters long.

Otherwise you will get an error because 2 Primary Keys end up being the same when you chop them off at eight characters.

pk.png


The easy way to change them is running this SQL...

Code: Select all

ALTER TABLE `household` CHANGE `household_id` `household_id` VARCHAR(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
ALTER TABLE `household_members` CHANGE `household_id` `household_id` VARCHAR(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;
ALTER TABLE `household_members` CHANGE `member_id` `member_id` VARCHAR(25) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;



Steven
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
Lala
Posts: 31
Joined: Thu Nov 07, 2024 11:46 pm
Has thanked: 8 times
Been thanked: 4 times

Re: Grid subform can only add one record at a time

Unread post by Lala »

Thank you so much - I think the JS function was one of my desperate attempts to sort the matter which I forgot to remove. Your help with the id length is invaluable - I'll go and do it now and pray that it works!!
kev1n
nuBuilder Team
Posts: 4292
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: Grid subform can only add one record at a time

Unread post by kev1n »

Hi Lala,

I just wanted to check if you were able to test Steven's suggestions and if it's working now. Thanks so much for your feedback!
Post Reply