Not linking subform

S

swas

Hi,

I have a form with a subform on it. The main form has a key field, and the
subform has this key field in its recordsource. Both are seperate tables and
no relationship has been set between the tables.

In the subform I need to display records where this common key field is not
necessarily set in the subform, so don't want to use master / child links,
rather I will manage the subforms recordsource myself (I assume this is my
only choice).

However the form still forces a master / slave relationship on this common
key field, so even if I change the subform recordset I can't display other
records. I have triple checked the linkmaster / linkschild properties are
cleared, and even deleted / inserted the subform again.

Have i done something wrong, or does Access automatically link these fields
regardless?

Thanks in advance.


swas
 
R

Rick Brandt

swas said:
Hi,

I have a form with a subform on it. The main form has a key field,
and the subform has this key field in its recordsource. Both are
seperate tables and no relationship has been set between the tables.

In the subform I need to display records where this common key field
is not necessarily set in the subform, so don't want to use master /
child links, rather I will manage the subforms recordsource myself (I
assume this is my only choice).

However the form still forces a master / slave relationship on this
common key field, so even if I change the subform recordset I can't
display other records. I have triple checked the linkmaster /
linkschild properties are cleared, and even deleted / inserted the
subform again.

Have i done something wrong, or does Access automatically link these
fields regardless?

Access made an assumption when you made the form/subform and automatically
entered values into the MasterLink and ChildLink properties of the subform
control. Simply clear those properties.
 
S

swas

Rick,

Thanks for the quick reply.

With the key field names changed in the form / subform queries to different
names, and in the onload event setting master / child links to "", the form
now works.

With the fields still named by their correct same name (BankDepositKey), I
get a "Specify Relationships" screen come up every time, even with the link
fields being set to "".

While the first situation should solve the problem, can I assume I can't
have a key field with the same name here?

Thanks again.

swas
 
R

Rick Brandt

swas said:
Rick,

Thanks for the quick reply.

With the key field names changed in the form / subform queries to
different names,

This should not have been necessary.
and in the onload event setting master / child links
to "", the form now works.

Why are you setting these in the Load event. You shoudl be able to just
clear them in design view and be done with it.
With the fields still named by their correct same name
(BankDepositKey), I get a "Specify Relationships" screen come up
every time, even with the link fields being set to "".

Every time when? Every time you open the form? I have never seen a
"Specify Relationships screen". Unless this is some stupidity introduced in
later versions there is something else going on here.
While the first situation should solve the problem, can I assume I
can't have a key field with the same name here?

Having them the same will cause more "assumptions" when you build forms and
queries, but otherwise should be no problem at all. Most of the assumptions
can be avoided by not using the wizards. They just keep you from learning
what you're doing anyway.
 
S

swas

Rick,

Again thanks for the reply.

I'm using Access 2007 but working on a 2003 mdb.

If I do a similar thing on an Access 2003 version, i don't have any problems.

Not sure which way to go from here.


Thanks


swas
 
R

Rick Brandt

swas said:
Rick,

Again thanks for the reply.

I'm using Access 2007 but working on a 2003 mdb.

If I do a similar thing on an Access 2003 version, i don't have any
problems.

Not sure which way to go from here.

Sorry, I have it installed but only open it when I've got a gun to my head.

How about entering MasterLink and ChildLink properties that are just
constants? Like just entering "1" in both of them?

Come to think of it though while the MasterLink will accept any valid
expression, the ChildLink might be required to be a field name from the
subform's RecordSource. You could always use a query as the subform's
RecordSource and add a field that contains "1" and then refer to that field
name for the ChildLink property.

Anything that causes the two properties to always match should cause the
subform to show all of its records.
 
S

Stuart McCall

Sorry, I have it installed but only open it when I've got a gun to my

I know what you're thinking. "Did he fire six shots or only five?" Well, to
tell you the truth, in all this excitement I kind of lost track myself. But
being as this is a .44 Magnum, the most powerful handgun in the world, and
would blow your head clean off, you've got to ask yourself a question: Do I
feel lucky? Well, do ya, punk?
 
S

swas

Rick,

Thanks again.

I'll have a play here for a while. I might even create a new form and bring
everything accross - I can't help thinking I have something corrupted in
there, although you would think similar problems would follow to an Access
2003 machine.


Appreciated.


swas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top