Selecting a specific field from a subform

  • Thread starter Thread starter Tom Hart
  • Start date Start date
T

Tom Hart

Hi All,

I need to select the value from a field on a subform and
pass it to another form. The subform may have one or
more entries. I am hoping for a way to point/select to a
certain row on the subform and then be able to identify
the value in a particular field.
 
Tom said:
I need to select the value from a field on a subform and
pass it to another form. The subform may have one or
more entries. I am hoping for a way to point/select to a
certain row on the subform and then be able to identify
the value in a particular field.


If you click on a control in a (sub)form, first the record
you clicked in will become the current record and then the
control will get the focus. It will remain the (sub)form's
active control until you change the focus to another control
on the (sub)form.

If you now click in the main form (e.g. a button) you can
still refer to the subform's control that had the focus by
using:

Me.subformcontrol.Form.ActiveControl
 
-----Original Message-----
Tom said:
I need to select the value from a field on a subform and
pass it to another form. The subform may have one or
more entries. I am hoping for a way to point/select to a
certain row on the subform and then be able to identify
the value in a particular field.


If you click on a control in a (sub)form, first the record
you clicked in will become the current record and then the
control will get the focus. It will remain the (sub) form's
active control until you change the focus to another control
on the (sub)form.

If you now click in the main form (e.g. a button) you can
still refer to the subform's control that had the focus by
using:

Me.subformcontrol.Form.ActiveControl
--
Marsh
MVP [MS Access]
.
I have tried to reference the subform by using a macro
and it is not working. I am using the SetValue and
referencing the active form as Forms!Subformname!
ControlName. Access is giving me a message that the
object is not available for Automation operations. Any
ideas?
 
-----Original Message-----
and it is not working. I am using the SetValue and
referencing the active form as Forms!Subformname!
ControlName. Access is giving me a message that the
object is not available for Automation operations.


A subform is not opened in its own right and, therefore is
not a member of the Forms collection. It is only being
displayed by the subform control on the mainform.

If you already know the name of the subform control that you
want to get the value from, then I guess I didn't understand
your original question. (The way I read it, you wanted to
reference whatever control the user had clicked on and
that's why I said to use the ActiveControl property.)

Since it appears that you only want to get a specific
control's value from the current record in the subform,
regardless of which control the user clicked on, the
reference would be:

Forms!mainformname.subformcontrolname.Form.controlname
 
-----Original Message-----
to
a

and it is not working. I am using the SetValue and
referencing the active form as Forms!Subformname!
ControlName. Access is giving me a message that the
object is not available for Automation operations.


A subform is not opened in its own right and, therefore is
not a member of the Forms collection. It is only being
displayed by the subform control on the mainform.

If you already know the name of the subform control that you
want to get the value from, then I guess I didn't understand
your original question. (The way I read it, you wanted to
reference whatever control the user had clicked on and
that's why I said to use the ActiveControl property.)

Since it appears that you only want to get a specific
control's value from the current record in the subform,
regardless of which control the user clicked on, the
reference would be:

Forms!mainformname.subformcontrolname.Form.controlname
--
Marsh
MVP [MS Access]
.
Thanks. Works great.
 
Back
Top