How to refer to subform2 from subform1

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

Hopefully this is a quick question for the gurus out there.

I have two subforms on a main form.

From subform1 I want to change the recordsource of subform2, how do I reference that?

I have tried Me.Parent.subform2.form.recordsource and get "You canceled the previous operation".

Karen
 
You refer to subforms via the Form property of the Control that *contains*
the subform, not the name of the Subform itself:

Me.Parent.subform2containercontrol.form.recordsource

When created using drag & drop, the container control is automatically given
the same name as the subform, so this might or might not be your problem.
It is often the source of confusion, so it's the first thing that popped
into my head.

However, that is *not* an error message I would expect to see due to an
incorrect reference so I suspect something else is going on.

Sorry this wasn't more help,

--
George Nicholson

Remove 'Junk' from return address.


Hopefully this is a quick question for the gurus out there.

I have two subforms on a main form.

From subform1 I want to change the recordsource of subform2, how do I
reference that?

I have tried Me.Parent.subform2.form.recordsource and get "You canceled the
previous operation".

Karen
 
Thanks George but subform2 is the container for the form. This is so
frustrating because I had it working yesterday then a 'compact' error wiped
out the VBA :(

Karen
 
I found it. One of the things I had to do yesterday was change a datatype
in a table to make it work so George, you were exactly right the error was
pointing to something else altogether.

Karen
 
Back
Top