Sub Forms (1 Viewer)

MaleNurse325

Registered User.
Local time
Today, 00:35
Joined
Jan 11, 2016
Messages
67
Hi,
I have a form called frmRegister on which is a sub form sfrmPriority They are linked Master = MaterID (an AutoNumber) and PriorID (again an AutoNumber) All works well until I try to add a record to the system and then the sub form sfrmPriorty is blank even when I start to add details to the frmRegister.
How do I link them from as soon as I start to populate the master form please?
:banghead::banghead::banghead::banghead::banghead::banghead::banghead:
 

mike60smart

Registered User.
Local time
Today, 08:35
Joined
Aug 6, 2017
Messages
1,904
Hi

Do you have MasterID as a Foreign Key in tblPriority??
 

MaleNurse325

Registered User.
Local time
Today, 00:35
Joined
Jan 11, 2016
Messages
67
it is the Primary Key. I will show my ignorance now and ask.. What is a foreign key?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:35
Joined
Jul 9, 2003
Messages
16,280
I recently did a set of videos on subforms. In particular I was explaining a "Many to Many Relationship". However along the way I went into detail about subforms. I suspect you might gather some useful information from the video "Synchronisation not Working" on this page:- http://www.niftyaccess.com/many-to-many-relationship/

From reading your question, I'm not quite clear on the arrangement you've got. But I'm wondering if you are linking two (ID) "identity Fields" together? This will not work, (I'm assuming they are both Auto-number Fields)...

Taking a step back from your explanation, what you need is on the main form a reference to one record, and this record will have a unique ID. Now looking at the records displayed in the subform there "Must Be" a field which contains, stores, utilise, the ID from the Main Form... But here's the thing, it must be in same field for every every RECORD displayed in the subform. The videos linked to weren't exactly designed to demonstrate this issue, however I think you can probably ferret it out.
 
Last edited:

mike60smart

Registered User.
Local time
Today, 08:35
Joined
Aug 6, 2017
Messages
1,904
Hi

Table structure should be along these lines

tblRegister
- RegisterID - Autonumber Primary Key (You are using MasterID.)
-(Other fields to describe the Register

tblPriority
-PriorityID - Autonumber - Primary Key)
-RegisterID - Number - Foreign Key (Linked to RegisterID from tblRegister)
-(Other fields to deal with Priorities)

So in tblRegister when you create your First Record you will have a Unique ID - 1

Then when you add data to your subform the Primary Key and the Foreign Keys will Populate automatically as you enter data in each of the Other Controls.
 

Users who are viewing this thread

Top Bottom