Reference object in subform of subfom in Access VBA Module

  • Thread starter Thread starter Clint Marshall
  • Start date Start date
C

Clint Marshall

I am struggling to reference an object in a subform of a subform in a Module
in Access 2000.

What is the proper syntax, or how do I do it?

Conceptually, here's where I want to get:

.Body =
Forms![frmmarketingworksheet].[sfrmRemarks].[ssfrmRemarksDataEntry].[Remark]
form
subform sub-subform object

This gives me an error saying it can't find the field '|' referred to in my
expression.

When I knock it all the way down to:

.Body = Forms![ssfrmRemarksDataEntry].[Remark]

it says it can't find the form.

How do I get to the object?

Thanks!

-Clint Marshall
 
You can *never* use a subform name to refer to a subform. (Stop & read that
again.:-)

You have to use the Form property of the control that *contains* the
subform. It returns a reference to the subform:

ParentForm.Subform1ControlName.Form.Subform2ControlName.Form.ObjectName

Sometimes the name of the container control is the same as the name of the
subform itself, which can be confusing. (Personally, the first thing I do
when placing a subform is make sure that the control and the subform have
different names or it eventually comes back to bite me.)
 
Actually, you also can use this syntax:

Forms!Subform1!Subform2!ControlOnSubform2

--

Ken Snell
<MS ACCESS MVP>


George Nicholson said:
You can *never* use a subform name to refer to a subform. (Stop & read
that again.:-)

You have to use the Form property of the control that *contains* the
subform. It returns a reference to the subform:


ParentForm.Subform1ControlName.Form.Subform2ControlName.Form.ObjectName

Sometimes the name of the container control is the same as the name of the
subform itself, which can be confusing. (Personally, the first thing I do
when placing a subform is make sure that the control and the subform have
different names or it eventually comes back to bite me.)
--
George Nicholson

Remove 'Junk' from return address.

Clint Marshall said:
I am struggling to reference an object in a subform of a subform in a
Module in Access 2000.

What is the proper syntax, or how do I do it?

Conceptually, here's where I want to get:

.Body =
Forms![frmmarketingworksheet].[sfrmRemarks].[ssfrmRemarksDataEntry].[Remark]
form subform sub-subform
object

This gives me an error saying it can't find the field '|' referred to in
my expression.

When I knock it all the way down to:

.Body = Forms![ssfrmRemarksDataEntry].[Remark]

it says it can't find the form.

How do I get to the object?

Thanks!

-Clint Marshall
 
Thank you both!
I finally got it working with:

Forms!frmmarketingworksheet!Remarks!ssfrmRemarksDataEntry!Remark
form subform1 subform2
control

Many thanks!

-Clint

Ken Snell said:
Actually, you also can use this syntax:

Forms!Subform1!Subform2!ControlOnSubform2

--

Ken Snell
<MS ACCESS MVP>


George Nicholson said:
You can *never* use a subform name to refer to a subform. (Stop & read
that again.:-)

You have to use the Form property of the control that *contains* the
subform. It returns a reference to the subform:


ParentForm.Subform1ControlName.Form.Subform2ControlName.Form.ObjectName

Sometimes the name of the container control is the same as the name of
the subform itself, which can be confusing. (Personally, the first thing
I do when placing a subform is make sure that the control and the subform
have different names or it eventually comes back to bite me.)
--
George Nicholson

Remove 'Junk' from return address.

Clint Marshall said:
I am struggling to reference an object in a subform of a subform in a
Module in Access 2000.

What is the proper syntax, or how do I do it?

Conceptually, here's where I want to get:

.Body =
Forms![frmmarketingworksheet].[sfrmRemarks].[ssfrmRemarksDataEntry].[Remark]
form subform sub-subform
object

This gives me an error saying it can't find the field '|' referred to in
my expression.

When I knock it all the way down to:

.Body = Forms![ssfrmRemarksDataEntry].[Remark]

it says it can't find the form.

How do I get to the object?

Thanks!

-Clint Marshall
 
Hi Ken:

Yeah, I know that the Form property is the default but I wanted to emphasize
that the Form property exists, and how it works, etc. I was intentionally
leaving the syntax shortcut lesson for another day :-)

I've been known to write out the full version in my code anyway (unless I'm
in a loop). Verbosity just seems more "readable" sometimes.
--
George Nicholson

Remove 'Junk' from return address.


Ken Snell said:
Actually, you also can use this syntax:

Forms!Subform1!Subform2!ControlOnSubform2

--

Ken Snell
<MS ACCESS MVP>


George Nicholson said:
You can *never* use a subform name to refer to a subform. (Stop & read
that again.:-)

You have to use the Form property of the control that *contains* the
subform. It returns a reference to the subform:


ParentForm.Subform1ControlName.Form.Subform2ControlName.Form.ObjectName

Sometimes the name of the container control is the same as the name of
the subform itself, which can be confusing. (Personally, the first thing
I do when placing a subform is make sure that the control and the subform
have different names or it eventually comes back to bite me.)
--
George Nicholson

Remove 'Junk' from return address.

Clint Marshall said:
I am struggling to reference an object in a subform of a subform in a
Module in Access 2000.

What is the proper syntax, or how do I do it?

Conceptually, here's where I want to get:

.Body =
Forms![frmmarketingworksheet].[sfrmRemarks].[ssfrmRemarksDataEntry].[Remark]
form subform sub-subform
object

This gives me an error saying it can't find the field '|' referred to in
my expression.

When I knock it all the way down to:

.Body = Forms![ssfrmRemarksDataEntry].[Remark]

it says it can't find the form.

How do I get to the object?

Thanks!

-Clint Marshall
 
No criticism was intended. Just wanted to add to your information by
providing additional information for the poster's knowledge.

:-)

--

Ken Snell
<MS ACCESS MVP>


George Nicholson said:
Hi Ken:

Yeah, I know that the Form property is the default but I wanted to
emphasize that the Form property exists, and how it works, etc. I was
intentionally leaving the syntax shortcut lesson for another day :-)

I've been known to write out the full version in my code anyway (unless
I'm in a loop). Verbosity just seems more "readable" sometimes.
--
George Nicholson

Remove 'Junk' from return address.


Ken Snell said:
Actually, you also can use this syntax:

Forms!Subform1!Subform2!ControlOnSubform2

--

Ken Snell
<MS ACCESS MVP>


George Nicholson said:
You can *never* use a subform name to refer to a subform. (Stop & read
that again.:-)

You have to use the Form property of the control that *contains* the
subform. It returns a reference to the subform:


ParentForm.Subform1ControlName.Form.Subform2ControlName.Form.ObjectName

Sometimes the name of the container control is the same as the name of
the subform itself, which can be confusing. (Personally, the first thing
I do when placing a subform is make sure that the control and the
subform have different names or it eventually comes back to bite me.)
--
George Nicholson

Remove 'Junk' from return address.

I am struggling to reference an object in a subform of a subform in a
Module in Access 2000.

What is the proper syntax, or how do I do it?

Conceptually, here's where I want to get:

.Body =
Forms![frmmarketingworksheet].[sfrmRemarks].[ssfrmRemarksDataEntry].[Remark]
form subform sub-subform
object

This gives me an error saying it can't find the field '|' referred to
in my expression.

When I knock it all the way down to:

.Body = Forms![ssfrmRemarksDataEntry].[Remark]

it says it can't find the form.

How do I get to the object?

Thanks!

-Clint Marshall
 
Back
Top