One to One relationship

  • Thread starter Thread starter Phil M.
  • Start date Start date
P

Phil M.

I have two tables. I have forms based on both.

In one of the forms, I want a command button that opens up the other form.
This should be a one to one relationship between the tables. When I click
the command button, It should open up the other form with only ONE record
relating to the original table/form.

How do I make a one to one relationship? I am used to one-to-many. Should
primary keys be linked in one to one relationships?

thanks
phil m
 
One to one relationship is when PKs are linked. This means that the two
tables are basically extensions of each other. Although it is possible
not to have records in one for PKs present in the other.
You can base both forms on a query that brings the two tables together,
and each form uses its own fields from the query. Then, base the other
form on the different fields from the same query, and when it opens,
reuse the recordset from the first form. This way they will be
synchronized when you move from record to record.

Pavel
 
I have two tables. I have forms based on both.

In one of the forms, I want a command button that opens up the other form.
This should be a one to one relationship between the tables.

No. It's not.

Forms ARE NOT TABLES. A Form is just a window onto a Table, or onto a
query pulling data from one or more tables. Opening a Form has no
connection whatsoever with relationships between tables.
When I click
the command button, It should open up the other form with only ONE record
relating to the original table/form.

It will, if you use the appropriate VBA code; if you just use the
wizard-generated code it will open the second form displaying its
entire recordsource. Perhaps you could post the button's click event
code with a description of what you want to do.
How do I make a one to one relationship? I am used to one-to-many. Should
primary keys be linked in one to one relationships?

Yes; or put a unique Index on the foreign key field in the "child"
table (one to one relationships still have a directionality). One to
one relationships are QUITE uncommon (they're useful for Subclassing
and for some types of field-level security but not much else); why do
you feel that you need a one-to-one?
 
John said:
Yes; or put a unique Index on the foreign key field in the "child"
table (one to one relationships still have a directionality). One to
one relationships are QUITE uncommon (they're useful for Subclassing
and for some types of field-level security but not much else); why do
you feel that you need a one-to-one?

I used them in an application ported to Palm. The Palm software uses
Subforms and it is much easier when each Palm SF is linked to its own
table. But the hierarchy of them is indeed 1 to 1. But it took me some
philosophy changing to figure out how ho run it all in Access after
being used to 1 to many relationships.

Pavel
 
Back
Top