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

Access 101

syntax for subforms .... by Psychpt
Posted: 1 Feb 01

Syntax for main/subforms

For these examples:
Mainform is the name of the top level form
Subform1 is the name of the subform CONTROL on mainform
Subform2 is the name of the subform CONTROL on the 1st subform.
            
    If you are on    
    Main form    Sub 1
To refer to a form property, like RecordSource        
On Mainform    Me.RecordSource    Me.Parent.RecordSource
On Sub 1    Me!Subform1.Form.RecordSource    Me.RecordSource
On Sub 2    Me!Subform1.Form!Subform2.Form.
RecordSource    Me!Subform2.Form.RecordSource
To refer to a control        
On Mainform    Me!ControlName    Me.Parent!ControlName
On Sub 1    Me!Subform1.Form!ControlName    Me!ControlName
On Sub 2    Me!Subform1.Form!Subform2.Form!
ControlName    Me!Subform2.Form!ControlName
To refer to a control property, like Enabled        
On Mainform    Me!ControlName.Enabled    Me.Parent!ControlName.Enabled
On Sub 1    Me!Subform1.Form!ControlName.Enabled    Me!ControlName.Enabled
On Sub 2    Me!Subform1.Form!Subform2.Form!
ControlName.Enabled    Me!Subform2.Form!ControlName.Enabled
To refer to a subform control property, like SourceObject        
On Mainform    N/A    N/A
On Sub 1    Me!Subform1.SourceObject    N/A
On Sub 2    Me!Subform1.Form!Subform2.SourceObject    Me!Subform2.SourceObject
        
    If you are on    
    Sub2    Not in these forms
To refer to a form property, like RecordSource        
On Mainform    Me.Parent.Parent.RecordSource    Forms!Mainform.RecordSource
On Sub 1    Me.Parent.RecordSource    Forms!Mainform!Subform1.Form.RecordSource
On Sub 2    Me.RecordSource    Forms!Mainform!Subform1.Form!Subform2.
Form.RecordSource
To refer to a control        
On Mainform    Me.Parent.Parent!ControlName    Forms!Mainform!ControlName
On Sub 1    Me.Parent!ControlName    Forms!Mainform!Subform1.Form!ControlName
On Sub 2    Me!ControlName    Forms!Mainform!Subform1.Form!Subform2.
Form!ControlName
To refer to a control property, like Enabled        
On Mainform    Me.Parent.Parent!ControlName.Enabled    Forms!Mainform!ControlName.Enabled
On Sub 1    Me.Parent!ControlName.Enabled    Forms!Mainform!Subform1.Form!ControlName.Enabled
On Sub 2    Me!ControlName.Enabled    Forms!Mainform!Subform1.Form!Subform2.
Form!ControlName.Enabled
To refer to a subform control property, like SourceObject        
On Mainform    N/A    N/A
On Sub 1    N/A    Forms!Mainform!Subform1.SourceObject
On Sub 2    N/A    Forms!Mainform!Subform1.Form!Subform2.
SourceObject


Back to Microsoft: Access Other topics FAQ Index
Back to Microsoft: Access Other topics 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