Set form to be the ParentForm

A

Andrew

I used the wizard to create two forms. Based on the one-to-many relationship
it decided which form was the parent form. I've switched the code in the
underlying modules and edited them accordingly. But where do I tell Access
which form is the Parent and which is the Child.

Thanks.
 
P

PC Datasheet

You don't! Access determines this on its own from the design of your tables
and the relationship between the tables. Access always creates the parent
form (main form) from the table on the one side of the relationship and the
child form (subform) from the table on the many side of the relationship.
The table on the one side is the table that has its primary key linked in
the relationship. The table on the many side is the table that has a foreign
key linked in the relationship. For example:

TblDepartment
DepartmentID
DepartmentName

TblEmployee
EmployeeID
DepartmentID
EmployeeName

DepartmentID (PK) in TblDepartment is linked to DepartmentID(FK) in
TblEmployee in the relationship. Access will automatically base the parent
form (main form) on TblDepartment and the child form (subform) on
TblEmployee. It can't be the other way even if you wanted!!!
 
A

Andrew

Instead of my asking a specific question, let me make it general.

I have a table called SHARES and a table SHAREHOLDERS. Each shareholder can
have many shares. But the main form needs to be SHARES. Then if the user
wants to get address information, etc about the shareholder he can call up
the form SHAREHOLDER. How would you accomplish this?
 
A

Arvin Meyer [MVP]

Andrew said:
Instead of my asking a specific question, let me make it general.

I have a table called SHARES and a table SHAREHOLDERS. Each shareholder can
have many shares. But the main form needs to be SHARES. Then if the user
wants to get address information, etc about the shareholder he can call up
the form SHAREHOLDER. How would you accomplish this?

If there are many shares, this is a many to many relationship. Normally, you
would have shareholders, as the main form, and shares as the subform. If you
prefer the other way around, it can be done as well. I'd build a main form
with the shares, and a subform with the shareholder's ID and name. Double
clicking on a shareholder record would open a separate po-up form with more
detailed information on the shareholder. The code to open that form would
be:

DoCmd.OpenForm "frmShareholderDetail" ,,, "ShareholderID=" &
Me.txtShareholderID
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Top