SubForms

R

Rob W

Greetings,

I have several subforms and they are all access form objects, however on one
of my main forms with VBA editor I can see the subform as an object.
Wheres the rest cannot be selected, using me.formname.requery leads to an
error describing how it cant find the object.

Have I not linked them correctly?
When viewing the design of the main form they appear with column details as
datasheets.

Can anyone advice?

Thanks
Rob
 
G

George Nicholson

1) In *design view*, only one instance of a subform is viewable/selectable.
If the subform is already open by itself, or appears on some other open
form, then you'll only see an empty placeholder in design view. Nothing
wrong there, that's how design view works: it can only show an open form
once.

2)
using me.formname.requery leads to an error describing how it cant find the
object.

Me.SubformControlName.Form.Requery
or, since Form is the default property of a SubformControl:
Me.SubformControlName.Requery

You can't reference a subform by its name. You can only refer to a subform
by the name of the *control* that is acting as the subform container. When
you drag and drop a form to create a subform the wizard *might* give the
container control the same name as the subform. Therefore, *sometimes* the
syntax you used actually works, but when it does, its misleading. I usually
make sure the control and form have different names to eliminate confusion.

Here's a pretty thorough overview of the proper syntax to help you wrap your
head around that one. Pretty simple, once you know about it.
http://mvps.org/access/forms/frm0031.htm


Also: FYI, the Forms collection consists only of currently open Forms.
Subforms are *not* included in the Forms collection because they are simply
not considered to be open forms. Therefore: Forms("mySubform") will also
generate an "object not found" error. This is not directly related to your
current problem, but once you run into one of these 2 subform issues, the
other isn't too far behind.
 

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