How to refer to subform2 from subform1

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
 
G

George Nicholson

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
 
K

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
 
K

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
 

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