Access VBA subform control

Murray Brown
Murray Brown used Ask the Experts™
on
Hi
I am trying to refer to a field called LastName in my subform called frmLicenseeList using frmLicenseeList.Form.LastName
It is nor working
What am I doing wrong?
Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
President / Owner
Most Valuable Expert 2017
Most Valuable Expert 2012
Commented:
Murray,

  Syntax is:

  Forms![frmLicenseeList]![<subform *control* name here>].Form.LastName

 The control name on the main form may not be one in the same as the subform name.  So if your control name was embMySubForm and the subform name was MySubForm, you would have:

  Forms![frmLicenseeList]![embMySubForm].Form.LastName


Jim.
John TsioumprisSoftware & Systems Engineer
Commented:
Form_frmLicenseeList.LastName 

Open in new window

For example
Form_frmLicenseeList.LastName.Text

Open in new window

Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
If it is from code in the main form, it will be:

LastName = Me!NameOfTheSubformControlHoldingFormfrmLicenseeList.Form!LastName.Value

Open in new window

Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014
Commented:
Not to beat this further, but be sure you're using the name of the Subform Control on your form, which may or may not be the same as the form you're using as a Subform. You can determine if you're working with a subform by selecting the control on the form and checking the Property Sheet >> Data tab. If you see a property named "Source Object", you've selected the right control
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thank you. That was very helpful

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial