Add data to SubFrom from Main Form (1 Viewer)

JPR

Registered User.
Local time
Today, 02:46
Joined
Jan 23, 2009
Messages
192
Hello,
I am creating a small db to manage member of a sports club.
I have a two main tables: Members and YearlyFees
Memebers is to store general info.
Yearlyfees is to add the yearly fee each member pays.
The unique code for both tables is ID.

I first add a new memeber, than save the record to the table Memebers. A small line of code will also save the ID to the table Memberfees.
To update a record I double click on the list box.
When I open the form, I would like to show a subform to add the yearly fees that each member pays yearly, but cannot find a solution.


Posting a sample file. Thank you for your help.
 

Attachments

  • Test.accdb
    716 KB · Views: 79

Ranman256

Well-known member
Local time
Today, 05:46
Joined
Apr 9, 2015
Messages
4,337
you dont need code to store the ID, the subform does it for you in the subform property:
LINK MASTER FIELDS = ID
LINK CHILD FIELDS = ID
 

JPR

Registered User.
Local time
Today, 02:46
Joined
Jan 23, 2009
Messages
192
Thank you for your reply. Actually this is the way the sub it’s setup.
 

mike60smart

Registered User.
Local time
Today, 10:46
Joined
Aug 6, 2017
Messages
1,905
Thank you for your reply. Actually this is the way the sub it’s setup.
No your tables are not setup correctly.
You should have a PK in Members table with a corresponding FK in YearlyFees Table

The PK in Both tables should NOT be ID

Members should be MemberID - Autonumber
YearlyFees should be MemberYearlyFeeID - Autonumber

In the YearlyFees table the FK should be MemberID - Number - Long Integer

Then in the relationship window you need to link both tables on MemberID

Also the record Source of your tables throws up a VB error for missing field Nano ??
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:46
Joined
Feb 19, 2002
Messages
43,275
Several bound controls in the subform are bound to columns that do not - and should not - appear in the recordsource so just remove the controls from the subform and make the fixes Mike suggested also.
 

Users who are viewing this thread

Top Bottom