Update information on a subform from another subform

R

RAM

I have form called Schedule with two subforms. One subform shows appointments
by date and the second subform show appointments by time. I want to update
the form showing appointments by time from the subform by date. I tried the
method
Forms!APT![0800] = [AppTime]. Forms!APT is the subform showing
appointments by time and the [AppTime] is on the suform showing appointments
by date. I get an error saying cant find the form APT referred to in your
Macro or VB Code.

Thanks in advance for any help
 
K

Klatuu

Subforms are not seen as form objects. They are seen as the Source Obect
property of the subform control on your main form. To reference a control on
a subform of the active form it would be:
Me.MySubFormControl.Form.ControlName

If on another Form it is slightly different
Forms!MyFormName!MySubFormControl.Form.ControlName

Note MySubFormControl is not the name of the form. It is the name of the
subform control on your main form.
 
D

Douglas J. Steele

You can't refer directly to the form being used as a subform: you must refer
to it through its parent form. (In actual fact, subforms aren't part of the
Forms collection, which shows all open forms. Only the parent form is in the
collection).

You'll need something like:

Forms![NameOfParentForm]![NameOfSubformControlOnParentForm].Form![NameOfControlOnSubform]

Note that depending on how you added the form as a subform, the name of the
subform control on the parent form may be different than the name of the
form being used as a subform.
 
R

RAM

I can update data from the subform to the main form. But I'm trying to
update data from subform to subform. I did not quite understand how to
implement your answer.
--
AccessRAM


Douglas J. Steele said:
You can't refer directly to the form being used as a subform: you must refer
to it through its parent form. (In actual fact, subforms aren't part of the
Forms collection, which shows all open forms. Only the parent form is in the
collection).

You'll need something like:

Forms![NameOfParentForm]![NameOfSubformControlOnParentForm].Form![NameOfControlOnSubform]

Note that depending on how you added the form as a subform, the name of the
subform control on the parent form may be different than the name of the
form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RAM said:
I have form called Schedule with two subforms. One subform shows
appointments
by date and the second subform show appointments by time. I want to
update
the form showing appointments by time from the subform by date. I tried
the
method
Forms!APT![0800] = [AppTime]. Forms!APT is the subform showing
appointments by time and the [AppTime] is on the suform showing
appointments
by date. I get an error saying cant find the form APT referred to in your
Macro or VB Code.

Thanks in advance for any help
 
D

Douglas J. Steele

Fields on subform 1 are referred to as

Forms![NameOfParentForm]![NameOfSubformControl1].Form![NameOfControlOnSubform1]

Fields on subform 2 are referred to as

Forms![NameOfParentForm]![NameOfSubformControl2].Form![NameOfControlOnSubform2]

Doesn't really matter whether your code is in the module associated with the
Parent form, with the form being used as Subform1 or with the form being
used as Subform2: that syntax will work everywhere.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RAM said:
I can update data from the subform to the main form. But I'm trying to
update data from subform to subform. I did not quite understand how to
implement your answer.
--
AccessRAM


Douglas J. Steele said:
You can't refer directly to the form being used as a subform: you must
refer
to it through its parent form. (In actual fact, subforms aren't part of
the
Forms collection, which shows all open forms. Only the parent form is in
the
collection).

You'll need something like:

Forms![NameOfParentForm]![NameOfSubformControlOnParentForm].Form![NameOfControlOnSubform]

Note that depending on how you added the form as a subform, the name of
the
subform control on the parent form may be different than the name of the
form being used as a subform.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RAM said:
I have form called Schedule with two subforms. One subform shows
appointments
by date and the second subform show appointments by time. I want to
update
the form showing appointments by time from the subform by date. I
tried
the
method
Forms!APT![0800] = [AppTime]. Forms!APT is the subform showing
appointments by time and the [AppTime] is on the suform showing
appointments
by date. I get an error saying cant find the form APT referred to in
your
Macro or VB Code.

Thanks in advance for any help
 
R

RAM

I got it figured out using the following code:
Forms![frmSchedule]![FrmAppTime]![800] = [Event]


Thanks for your help
 
D

Douglas J. Steele

You're missing the .Form in there. While it may be working on your present
version of Access, it's possible that it will stop working if a future
service pack causes Access to adhere closer to the correct syntax, and it
likely won't upsize properly to Access 2007.

Forms![frmSchedule]![FrmAppTime].Form![800] = [Event]


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


RAM said:
I got it figured out using the following code:
Forms![frmSchedule]![FrmAppTime]![800] = [Event]


Thanks for your help
--
AccessRAM


RAM said:
I have form called Schedule with two subforms. One subform shows
appointments
by date and the second subform show appointments by time. I want to
update
the form showing appointments by time from the subform by date. I tried
the
method
Forms!APT![0800] = [AppTime]. Forms!APT is the subform showing
appointments by time and the [AppTime] is on the suform showing
appointments
by date. I get an error saying cant find the form APT referred to in
your
Macro or VB Code.

Thanks in advance for any help
 
C

Clif McIrvin

I completely missed that .Form when I found the syntax for getting to
subform
controls -- that's good to know, Thanks!

I have never been clear on the distinction between the "." and "!" in
the syntax,
and I never seem to be able to find my way back to references that I
have
stumbled across --- would someone please post an explanation, or point
me
towards an explanation?

tia
 
D

Douglas J. Steele

The usual advice is that you use ! for things you created (such as forms or
controls on forms) and . for things Access created (such as properties).
However, you might read what Andy Baron's got at
http://my.advisor.com/doc/05352

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I completely missed that .Form when I found the syntax for getting to
subform
controls -- that's good to know, Thanks!

I have never been clear on the distinction between the "." and "!" in
the syntax,
and I never seem to be able to find my way back to references that I
have
stumbled across --- would someone please post an explanation, or point
me
towards an explanation?

tia
 

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