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.
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]
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>...
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.
##
#############################################################################
You want to do the following:
MainForm_name!Subform_name.Form!Subform_Field_name
Good luck,
Eran berger