Subform Referencing

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

Guest

I am having trouble referencing subforms; specifically referencing code
behind a subform or passing the name of a sub form to a variable and then
using it in a With statement. I am leaving out some detail because this code
works with three other forms, it fails only on the subform name.

located in the afterupdate part of the main form Inquiry is :

MeForm = "frm Management SubForm"
Call PeopleCheck

and PeopleCheck is:
With Forms(MeForm)
StatOne = .RepInactive
StatTwo = .RepHiSup
.[RepFull].ForeColor = ColorCheck(StatOne, StatTwo)
End With
If there is no solution the the above example, how would you reference a
public procedure behind the subform from the main form. And lastly, is there
a link to a document that explaines the naming conventions so I can learn
this stuff. Many thanks for your efforts.
Thanks
Michael
 
The most widely-used naming convention for Microsoft Access is the Reddick
Naming Convention. You'll find it described at
www.xoc.net/standards/default.asp .

From code in the main form's module, you reference the Form embedded in a
Subform control, as :

Me!<nameofsubformcontrol>.Form

In general, a Form must be "Open" for you to refer to a Public procedure in
its module, and strictly speaking, a Form displayed in a Subform Control
isn't "Open" but exists as the Form property of the Subform Control.
However, executing a Public Sub in the module of the Form embedded in a
Subform control appears to be an exception to that -- out of interest, I
just tried it, and it executed the Sub just-fine-thankee, using the
following:

Me.sbfOrderDetails.Form.FoundMe

Larry Linson
Microsoft Access MVP
 
Thanks Larry, for the link and the solution. I discovered I was referencing
the source object rather then the name. There seems to be three property
options with a sub form so I managed to miss the one with the name. The name
passing as a parameter did not work, but the sub has so little code behind
it, I will execute the commands there rather than in a module.
Cheers,
Michael

Larry Linson said:
The most widely-used naming convention for Microsoft Access is the Reddick
Naming Convention. You'll find it described at
www.xoc.net/standards/default.asp .

From code in the main form's module, you reference the Form embedded in a
Subform control, as :

Me!<nameofsubformcontrol>.Form

In general, a Form must be "Open" for you to refer to a Public procedure in
its module, and strictly speaking, a Form displayed in a Subform Control
isn't "Open" but exists as the Form property of the Subform Control.
However, executing a Public Sub in the module of the Form embedded in a
Subform control appears to be an exception to that -- out of interest, I
just tried it, and it executed the Sub just-fine-thankee, using the
following:

Me.sbfOrderDetails.Form.FoundMe

Larry Linson
Microsoft Access MVP


apollo8359 said:
I am having trouble referencing subforms; specifically referencing code
behind a subform or passing the name of a sub form to a variable and then
using it in a With statement. I am leaving out some detail because this
code
works with three other forms, it fails only on the subform name.

located in the afterupdate part of the main form Inquiry is :

MeForm = "frm Management SubForm"
Call PeopleCheck

and PeopleCheck is:
With Forms(MeForm)
StatOne = .RepInactive
StatTwo = .RepHiSup
.[RepFull].ForeColor = ColorCheck(StatOne, StatTwo)
End With
If there is no solution the the above example, how would you reference a
public procedure behind the subform from the main form. And lastly, is
there
a link to a document that explaines the naming conventions so I can learn
this stuff. Many thanks for your efforts.
Thanks
Michael
 

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

Similar Threads


Back
Top