Manipulating subform controls via a module

G

Guest

I’m having some difficulty manipulating controls on a subform. Here is the
setup:

- The parent form is called frmMain. It has a frame on it called subFrame
where the subform resides. The frame is not bound in the properties but its
SourceObject is set in code because several subforms use the same frame.

- The subform in question is called fsubStatEntry. It has many controls,
but among those I want to manipulate are a label called lblMetricScore and a
text box called txtMetricScore. The query that fsubStatEntry is based on is
called qryStatistics.

The plan is that when certain events take place, the caption of
lblMetricScore would be changed and the source of txtMetricScore would be
changed to a different field from the underlying query. I can get this to
work fine when using the code such as me.txtMetricScore.ControlSource = “QAâ€
on the fsubStatEntry directly. However, because there are several different
events that can trigger this and there are many different possible changes to
each control, I am trying to put all the code into a module. Using “me.â€
obviously doesn’t work from the module, because the controls aren’t part of
the module’s “me†object. Can anyone explain what the code needs to look
like when fired from the module? I have tried a number of different ways but
haven’t been able to come up with a functional code string.
 
A

Allen Browne

Jeff, I assume that what you called the "frame" is a subform control?
So the subform control is named subFrame.

If so, you can refer to the form in the subform control like this:
Dim frm As Form
Set frm = Me.subFrame.Form

Now you can use frm anywhere you could use Me in the form's own module.
 
G

Guest

Thanks for the tip, Allen. Not the solution I expected to see, but
interesting... I will have to try that method out. I actually managed to get
the code working after checking out some additional posts and going over them
with my coworkers. For anyone else who might read this, the way I set up the
code was as follows:

Forms!frmMain!subFrame.Form.lblMetricScore.Caption = "QA"

....jeff...
 

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