Referring to Other Subform on Same form

C

Casey

I have a subform that is located on a main form. I
also have another subform on that same main form.

I will refer to them as subform1, subform2, and
mainform. The field on subform1 I will refer to as
field1. The field on subform2 I will refer to as field2.

After the update of field1 on subform1,I want
subform2 to requery (subform2 holds field2).

I know how to create a macro with the requery action,
and assign it to the afterupdate property of field1 on
subform1. I just need how to refer to subform2 in order
to requery it. I have tried something similar to what is
below but it does not work.

[Forms].[MainForm].[subform2].[form].[Field2]

Is there a way that I can communicate with subform2
in order to get it to requery.

If you know how I would refer to it, and you have
time to let me know, I would appreciate any help.

Thank you, and have a nice evening.

Casey
 
W

Wayne Morgan

I checked Requery in the macro window and it says to use only the name of the control
rather than the full syntax, so I'm guessing you can't do it with a macro. However, it can
be done with VBA. Starting from your name example:

Forms!MainForm!NameOfSubformControl.Form!txtField2.Requery
or
Me.Parent!NameOfSubformControl.Form!txtField2.Requery

You would requery the control, not the field. The NameOfSubformControl is the name of the
control on the main form that holds the subform, not necessarily the name of the subform
itself. To get the name of the control holding the subform, open the main form in design
mode. If the subform looks like a white box, you are looking at the control, click it and
look in the Properties sheet to see its name. If the subform looks like a form, click it
ONE time and look in the Properties sheet to get the name of the subform control. If you
click a second time you will be in the subform and the Properties sheet will show the name
of the form, not the control holding it.
 
C

Casey

Thanks Wayne, I'll try something like what you
recommended.

Casey
-----Original Message-----
I checked Requery in the macro window and it says to use only the name of the control
rather than the full syntax, so I'm guessing you can't do
it with a macro. However, it can
be done with VBA. Starting from your name example:

Forms!MainForm!NameOfSubformControl.Form!txtField2.Requery
or
Me.Parent!NameOfSubformControl.Form!txtField2.Requery

You would requery the control, not the field. The
NameOfSubformControl is the name of the
control on the main form that holds the subform, not
necessarily the name of the subform
itself. To get the name of the control holding the
subform, open the main form in design
mode. If the subform looks like a white box, you are
looking at the control, click it and
look in the Properties sheet to see its name. If the
subform looks like a form, click it
ONE time and look in the Properties sheet to get the name of the subform control. If you
click a second time you will be in the subform and the
Properties sheet will show the name
of the form, not the control holding it.

--
Wayne Morgan
Microsoft Access MVP


Casey said:
I have a subform that is located on a main form. I
also have another subform on that same main form.

I will refer to them as subform1, subform2, and
mainform. The field on subform1 I will refer to as
field1. The field on subform2 I will refer to as field2.

After the update of field1 on subform1,I want
subform2 to requery (subform2 holds field2).

I know how to create a macro with the requery action,
and assign it to the afterupdate property of field1 on
subform1. I just need how to refer to subform2 in order
to requery it. I have tried something similar to what is
below but it does not work.

[Forms].[MainForm].[subform2].[form].[Field2]

Is there a way that I can communicate with subform2
in order to get it to requery.

If you know how I would refer to it, and you have
time to let me know, I would appreciate any help.

Thank you, and have a nice evening.

Casey


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top