INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How to

How do I set a control in a subform from the main form (and vice versa)? by raymondo
Posted: 19 Jul 02 (Edited 22 Jul 02)

IÆve seen a few of these type questions floating about so here are a few tips.
LetÆs call our forms myMainFrm and mySubFrm.  Trying to use an expression like

Forms!mySubFrm![aControl] = aValue

from myMainFrm wonÆt work because when a mainform-subform is opened, only the main form figures as part of the Forms collection.

The correct syntax is

Forms!myMainFrm!mySubFrm![aControl] = aValue

which can be shortened to

Me!mySubFrm![aControl] = aValue

for procedures attached to myMainFrm. Essentially, the subform is just like any other control on the main form.

When in the subform, it is still only myMainFrm that figures as part of the Forms collection.
ôMeö however, as you would expect, refers to mySubForm.
So, to talk to myMainFrm from mySubFrm the correct syntax is

Forms!myMainFrm![anotherControl] = anotherValue

If the procedure is attached to mySubFrm then you could use ôMeö as follows:

Me.Parent![anotherControl] = anotherValue

I hope this helps.

Back to Microsoft: Access Forms FAQ Index
Back to Microsoft: Access Forms Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close