Find Name of Subform?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:

I created a query and then made it a subform. Everything works well except
the ability to requery the subform. When I try to compile the script, I
receive an error because I apparently have the wrong name of the subform
[using the caption].

OK, so I clicked on the subform's properties and looked everywhere, however,
I cannot find the name of the subform. This has happened before. Am I missing
something obvious?

Thanks,
Robert
 
Open main form. Click on top edge of control that holds the subform. Open
Properties window. Click on Other tab. Name will be in the Name box.
 
Hello Ken:

Thanks, I tried that technique and found the subform name. But I don't get
it, how in the world would anyone know that trick? Why isn't the form name
listed with the other properties of the subform?

Thanks,
Robert
 
A subform is contained within a subform control on a main form. So that
subform control has all the properties of the subform object -- the name,
data linking fields, etc. The actual name of the form that is serving as the
subform is found in the subform control's Source Object property.

A subform is not actually open in its own right, and actually many forms can
use the same "subform" -- hence, a subform itself does not contain
properties that are directly pertainable to the subform control because
those properties would change for each main form.

In ACCESS, the subform is a child of the main form, hence you must reference
the subform through the main form, just as you would a textbox control on
the main form.

Let me know if I've not answered your question clearly -- I'm currently
finishing up a 16-hour workday and I'm not sure if I'm making sense.... < g
 
Thanks, I tried that technique and found
the subform name.

Actually, you found the name of the Subform Control.
But I don't get it, how in the world would
anyone know that trick?

It's not a "trick" -- it is the same identical way you find the name of any
other Control. One would learn this when learning the basics of Access,
using self-study books, or online training (see http://office.microsoft.com
and other providers), or, well, asking in newsgroups such as this one.
Why isn't the form name listed with the
other properties of the subform?

The name of the Form embedded in the Subform Control can be found as the
SourceObject property, but it is of little/no use because you do not refer
to the embedded Form by name. From the main Form's code, you refer to a
Control (txtA) in the Form embedded in the SubformControl (sbfB) like this:

Me!sbfB.Form!txtA

(the "!"s in this statement can be replaced with "." if you prefer, but the
"." between sbfB and "Form" cannot be replaced by a "!", because Form is a
Property of the Subform Control, not a member of a Collection).

You don't requery the Form that is embedded in the Subform Control, you
requery the Subform Control itself. The embedded Form is not "open" when
displayed in the Subform Control -- you will not find it in the Forms
collection.

By now, maybe my trying to be very precise in nomenclature has already led
to you realize: There is no Access object called a "Subform"; there is a
Subform Control, into which a Form can be embedded -- we sometimes take the
shortcut of just calling the Subform Control and its embedded Form a
"Subform" but that can be confusing, as it seems to have been for you.

Larry Linson
Microsoft Access MVP
 
Larry and Ken:

Thanks so much for taking the time to write such a detailed explanation. It
will take awhile to digest all of that info, however, it was extremely
helpful and provided new insight into Access.

Hope both of you have a great day!

Oh by the way, on a completely different note, maybe you guys can check out
my request for help in "Forms Design"? We are Trainers and we register
students for our training classes here at work in Access 2003. When a
customer sends an email registering for one of our courses, after we enter
his/her info in our database, we in turn want to click a button on the form,
and automatically send an EMAIL reply to that customer via Outlook 2003.

I've only had one reply so far and it doesn't seem to work. Maybe you guys
have a simple solution to send only one email message confirming the
student's registgration in a specific class.

Thanks,
Robert
 
Ken and Larry:

Whoops, the send email question was asked in the FORMS CODING forum.

Robert
 
Unfortunately, I've not worked with sending emails very much. But many other
MVPs have, so perhaps one will post an answer for you.
 
Back
Top