Question on Subforms?

Castaway4

Registered User.
Local time
Today, 12:52
Joined
Dec 20, 2001
Messages
14
Is it possible to have a form with a subform that is linked to four other subforms:confused:

something like this see attached jpg

if possible, how do you link the subform to the other four subforms if you can only have one autonumber per table

Thanks
 

Attachments

  • screen.jpg
    screen.jpg
    85.3 KB · Views: 130
Last edited:
I am looking at your other post. But I am not understand how it works.

Thanks
 
if you can only have one autonumber per table
First off I fear you misunderstand the autonumber, primary keys and foreign keys.

1. The autonumber can only be used once in a table, you are correct. But a table does not need more than one autonumber. The autonumber is used as a surrogate key and if set as the primary it has it so that the same number can't be used there more than one time.

2. When you have other tables you want to link to them, your other tables probably will have an autonumber primary key as well. HOWEVER, you do NOT link those to the other tables. The other tables would have a FOREIGN KEY which is basically the same field as the parent table but as a Long Integer. See this sample:

table - Employees
EmployeeID - Autonumber (PK)
FirstName
LastName

table - Departments
DepartmentID - Autonumber (PK)
DepartmentName

table - EmployeeDepartments (a junction table)
EmployeeDepartmentID - Autonumber (PK)
EmployeeID - Long Integer (FK) - the autonumber from the Employees table
DepartmentID - Long Integer (FK) - the autonumber from the Departments table


So see how they are used in the tables? Then you have your links for the forms - the main form here in my example would be the Employees and then it would have a subform consisting of the EmployeeDepartments table and the link would be
MASTER - EmployeeID
CHILD - EmployeeID

And we don't even include the Departments table in that because it is a completely and separate entity.
 
I am looking at your other post. But I am not understand how it works.

Thanks

As explained by BOB, actually you should aware of RDBMS (Relational Database Management System) google for it, where your Primary Key (PK) in your table should be connected to your other table as a Foreign Key (FK).

This call normalization of the tables also, Which mean you can break your information or data in multi tables and then join those tables through a unique key i.e (PK) and (FK) concept.

If you read the post it says:

create an unbound textbox control (hidden) on your main form
name it txtLink
on your second child form: do this:
Code:
PHP:
Private Sub Form_Current()
On Error GoTo Err
        If Not IsNull(Me![yourRecID]) Then
            Forms![Main_Form]![txtLink] = Me![yourRecID]
        End If

Exit_Err:
Exit Sub
Err:
        MsgBox Err.Description
        Resume Exit_Err
End Sub

This will give you the current ID of your second child form on runtime:
you can now refere 'txtLink' field/control in your second child form as:
LinkMasterFields: Team_ID;txtlink;dtelink
LinkChildFields: F_Team_ID;F_Task_ID;F_Date_ID
Note:
Change the feildnames according to your database field-names.

Hope methode will solve your problem.
 

Users who are viewing this thread

Back
Top Bottom