By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,397 Members | 1,467 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,397 IT Pros & Developers. It's quick & easy.

data entry in subform - fk doesn't undertake value of pk

P: 5
Hello!

I have a problem with my fk's behind the main form. Here is the situation:

Table PERSONS is behind the main form and table BANK_DETAILS is behind the subform on a different tab. There is a one-to-one relationship between PERSONS with FK_ACCOUNT_CODE and BANK_DETAILS with ACCOUNT_CODE as pk in autonumber format.
When I added a new Person in the main form and I switch to the tab for the bank details, I can add a new record in BANK_DETAILS, but the value of the pk ACCOUNT_CODE would not be passed through to the fk in table PERSONS.

I am not good at programming! So what could I do?

I would be very grateful about suggestions! Thanks!
Dec 13 '07 #1
Share this Question
Share on Google+
6 Replies


Rabbit
Expert Mod 10K+
P: 12,396
Check the parent/child properties of the subform control.
Dec 13 '07 #2

P: 5
parent/child fields are linked. Nothing happens. Is there a possibility to write a setvalue statement for the pk control, maybe as after update event? can anybody help me with that, because I am not good at programming?

Thanks!
Jan 10 '08 #3

Rabbit
Expert Mod 10K+
P: 12,396
I think you've got it backwards, the primary key should be in the main form while the foreign key should be in the subform.

Rather than linking the two tables on account id it should like on a person id. The way that parent/child fields work is that the field in the parent table populates the field in the child table. You should either flip the tables or change the primary key field.
Jan 10 '08 #4

P: 5
Thanks for the answer!
I think I'm gonna try to switch the keys. Just one more question: might it have something to do with the tab control? I've got the tab control on the mainform and the subform is on the 2nd tab.
Jan 11 '08 #5

P: 5
Alright, thanks for the answers! I changed the keys and everything is working fine!
Jan 11 '08 #6

Rabbit
Expert Mod 10K+
P: 12,396
The tabs don't affect controls in any way other than which are visible depending on the tab you're on.

Subforms were just set up to work with the main form populating the linked field on the subform and not the other way around.
Jan 11 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.