usage access.subform

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi,

Can anyone tell me how i can use the access class subform?

I want to improve my code by using subform.name in code where i reference
the subform's name as a string.

Here's an example:

Set Forms(Me.Name).Controls("subfrm").Form.Recordset = rst

Should look like:

Set Forms(Me.Name).Controls(subform.name).Form.Recordset = rst
 
Jason said:
Can anyone tell me how i can use the access class subform?

I want to improve my code by using subform.name in code where i reference
the subform's name as a string.

Here's an example:

Set Forms(Me.Name).Controls("subfrm").Form.Recordset = rst

Should look like:

Set Forms(Me.Name).Controls(subform.name).Form.Recordset = rst


This question seems a little odd to me. You can write
...Controls!subfrm.Form...
...Controls("subfrm").Form...
...Controls(subfrm.Name).Form...
but all of those syntaxes require you to know the name of
the subform **control** that you are referring to. Note
that the name of the form displayed in the subform control
is not involved in the reference.

Another way I might interpret your question is if the focus
in somewhere in the subform, then the subform control will
be the active control on the main form and you could refer
to it this way:
in the mainform's module
Me.ActiveControl.Form...
in the subform's module
Parent.ActiveControl.Form...
 
Hi Marshall,

Is there any to not hardcode the a subform's name in the way i want to do
it?
 
You still need to explain what you want here. Do you mean
the name of the subform **control** or the form that it is
displaying.

I still don't understand what you mean by refer to a control
without knowing which control you want to refer to. This
sounds like a self contradiction to me.

The example syntax you posted your question:
Forms(Me.Name).Controls....
is a redundant way to write:
Me.Controls....
so that example really doesn't help clarify what you want
here.
 
Back
Top