SubForm Referencing

G

Guest

I have code in one place that checks the color of a person's name from many
different forms by using a with statement and a variable (MeForm) to pass the
form name, the code will execute from any form. This cuts down on duplicate
code. However, I have one subform and I can't get the proper name for it. The
parent name is "frm Inquiry" and the sub is "frm Management SubForm" and this
sub has a value called InActive and if checked the person has left the
company and the color should be blue. I need help on the syntax of assigning
the variable the full name from parent to sub form. In this situation the Me.
prefix won't work. What I have so far is this:

MeForm = "Forms![frm Inquiry].[frm Management SubForm].Form"

the with statement goes like this:

With Forms(MeForm) <- blows up on this line
if .InActive = true then
etc.
Any help would be greatly appreciated.
Sincerely,
Michael
 
G

Guest

Check to see if your subform has a child name as well as a form name. In
your form's design view, with the property window showing, click one time on
your subform. The Name property may show a different name than the subform's,
with the name of the subform being the Source Object. For example, if you
have a form named frmInquiry and a subform called frmManagementSubform, the
subform's child name might be chdInquiry when it's inside frmInquiry. So the
reference in code to the subform becomes

Forms!frmInquiry!chdInquiry.Form

Hope this helps.
 
L

Larry Linson

apollo8359 said:
the with statement goes like this:

With Forms(MeForm) <- blows up on this line
if .InActive = true then
etc.

I don't use "With" because it makes it more difficult for anyone following
me on maintenance of the database. But, if "MeForm" is, as I understand, the
name of the Form embedded in the Subform Control, then that is incorrect
syntax... the Form displayed in a Subform Control is not "Open" and, thus,
not part of the Forms Collection. The instance of the Form displayed in the
Subform Control "exists" as the Form property of the Subform Control.

You will not necessarily be able to use the same notation when you refer to
both main Forms and Forms displayed in a Subform Control. I'd suggest you
pass the reference to the Form as an Object variable of type Form when you
call the procedure.

Alternatively, you can create a separate copy of the procedure for use by /
for Forms displayed in Subform Control.

Larry Linson
Microsoft Access MVP
 

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