Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to reference an object on a subform

326 views
Skip to first unread message

Rod Mendenhall, Jr.

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

I have what is probably a very basic question with a simple answer, but I
can not find an answer anywhere.

I would like to reference a field on a subform from a procedure of another
form. I have tried several variations of the following
"DoCmd.SelectObject" to select the form with no success. Each time I get
an error message saying that the form cannot be found (I did verify the
spelling of the subform). Here are the two variations that I have tried:

1. DoCmd.SelectObject acForm, "Subform_name"

2. DoCmd.SelectObject acForm, "Mainform_name!Subform_name"

Am I missing something really supid? Or am I trying to do something that
is not possible?


Thanks,

Rod Mendenhall

Opinions expressed herein are my own and may not represent those of my employer.


IndPhantom

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

>From: ramend...@mmm.com (Rod Mendenhall, Jr.)
>Newsgroups: comp.databases.ms-access
>Subject: How to reference an object on a subform
>Date: 15 Aug 1997 03:08:34 GMT
>Organization: 3M - St. Paul, MN 55144-1000 US
>Lines: 20
>Message-ID: <01bca927$d8111c70$dc0e0ca9@pooky>
>X-Newsreader: Microsoft Internet News 4.70.1161

Rod,
After you create a subform or subreport, you can refer to the values of
the subform or subreport's controls in an expression. For example, you
can attach a macro or event procedure to a button on a form that uses an
expression to set the value of a control on a subform. (Note that when
you refer to a subform in an expression on the main form, you are actually
referring to the form, defined in the subform control's SourceObject
property, associated with the subform control a subform control is a type
of control on the main form.)
To refer to the value of a control on a subform or subreport in an
expression, type the identifier for the Form or Report property that
represents the subform or subreport, followed by the ! operator and the
control identifier.

To refer to a control on a subform or subreport, use the following syntax:

Forms![main form name]![subform control name].Form![control name]

-Or-

Reports![main report name]![subreport control name].Report![
control name]

Larry Tubbs

unread,
Aug 15, 1997, 3:00:00 AM8/15/97
to

Hello Rod,

If you simply want to set the focus to a control on a subform, you can do it
like this:

Forms![Main Form Name]![Sub Form CONTROL Name on the Main
Form].Form![Control Name on the Subform].SetFocus

Remember that the name of the Subform and the name of the Subform control on
the main form are not necessarily the same. I hope this helps,


--

Larry Tubbs, MCPS, MCSD
Silverleaf Resorts Inc., NYSE: SVR
mailto:ltu...@sprintmail.com
http://www.geocities.com/ResearchTriangle/5727/

Rod Mendenhall, Jr. wrote in article <01bca927$d8111c70$dc0e0ca9@pooky>...

Ron Myer

unread,
Aug 16, 1997, 3:00:00 AM8/16/97
to Rod Mendenhall, Jr.

Rod Mendenhall, Jr. wrote:
>
> I have what is probably a very basic question with a simple answer, but I
> can not find an answer anywhere.
>
> I would like to reference a field on a subform from a procedure of another
> form. I have tried several variations of the following
> "DoCmd.SelectObject" to select the form with no success. Each time I get
> an error message saying that the form cannot be found (I did verify the
> spelling of the subform). Here are the two variations that I have tried:
>
> 1. DoCmd.SelectObject acForm, "Subform_name"
>
> 2. DoCmd.SelectObject acForm, "Mainform_name!Subform_name"
>
> Am I missing something really supid? Or am I trying to do something that
> is not possible?
>
> Thanks,
>
> Rod Mendenhall
>
> Opinions expressed herein are my own and may not represent those of my employer.

Hi Rod,
In Access Basic it is ...
Forms!MyFormName!SubFormName.Form!FieldName
hth,
Ron Myer

--
#############################################################################
## Available for Development in Access 2.0 and Access '97. Reasonable
Rates ##
## Telecommute Only: Reply Via EMail.
##
#############################################################################

Eran Berger

unread,
Aug 21, 1997, 3:00:00 AM8/21/97
to

Rod Mendenhall, Jr. wrote:
>
> I have what is probably a very basic question with a simple answer, but I
> can not find an answer anywhere.
>
> I would like to reference a field on a subform from a procedure of another
> form. I have tried several variations of the following
> "DoCmd.SelectObject" to select the form with no success. Each time I get
> an error message saying that the form cannot be found (I did verify the
> spelling of the subform). Here are the two variations that I have tried:
>
> 1. DoCmd.SelectObject acForm, "Subform_name"
>
> 2. DoCmd.SelectObject acForm, "Mainform_name!Subform_name"
>
> Am I missing something really supid? Or am I trying to do something that
> is not possible?
>
> Thanks,
>
> Rod Mendenhall
>
> Opinions expressed herein are my own and may not represent those of my employer.


You want to do the following:

MainForm_name!Subform_name.Form!Subform_Field_name

Good luck,

Eran berger

0 new messages