'Important: Differentiate between a form, a subform, and a subform control
'The first two are forms; the third is a control which is placed on a form and
'points to another form.
'frmSub is NOT necessarily the name of the source subform. Rather it is the name of
'the control I placed on my form. Click on the subform border to select it.
'The property sheet should start Subform/SubReport if it has Form instead, you
'miss targetted and chose the form to which the control points. You know you
'have it when the resize handles appear around the subform control.
'In my case, I made both my Subform/Subreport.Name ="frmSub" and
'Subform/Subreport.SourceObject = "frmSub" to avoid conflict. But just so you know,
'The code below requires "frmSub" to be the
Subform/Subreport.Name
'Also note you can nest up to seven times using:
'
Forms("frmMain"
("frmSub"
("frmSub2"
("frmSub3"
...("txtField"
Option Compare Database
Option Explicit
Private Sub cmdSet_Click()
'Using complete syntax to set a field on a sub form
'Forms("frmMain"

.Controls("frmSub"

.Form.Controls("txtLName"

.Value = "YourName"
'Same thing but taking advantage of Access's default control properties
'Forms("frmMain"

("frmSub"

("txtLName"

= "YourName"
'Same thing but but frmMain is current form so no need to reference
frmSub("txtLName"
= "YourName"
End Sub
Private Sub cmdGet_Click()
Dim strLName As String
'Using complete syntax to get the value from a field on a subform
'strLName = Forms("frmMain"

.Controls("frmSub"

.Form.Controls("txtLName"

.Value
'Same thing but taking advantage of Access's default control properties
'strLName = Forms("frmMain"

("frmSub"

("txtLName"
'Same thing but but frmMain is current form so no need to reference
strLName = frmSub("txtLName"
MsgBox strLName
End Sub