Click here to Skip to main content
16,021,430 members
Please Sign up or sign in to vote.
4.33/5 (2 votes)
See more:
This is not your simple reference to a control on a subform. I need to set the caption for a label from an event in a subform. Here's the layout:

MainForm
- Subform1 (of MainForm)

- Subform2 (of MainForm)
- Label1 on Subform2



in the OnCurrent event of Subform1, I need to set the caption of Label1

I've tried everything I can think of.

Me.Parent!Subform2!Label1.Caption = "lorem ipsum"

Me!Forms!MainForm.Controls!Subform2!Label1.Caption = "lorem ipsum"

and others. Nothing works. Error is:

you entered an expression that has an invalid reference to the property form/report

TIA, AR.
Posted
Updated 16-Dec-13 10:23am
v2

1 solution

Try this:

VB
Dim lbl As Label
Set lbl = Me.Parent.Controls("SubForm2").Form.Controls("Label1")
lbl.Caption = "lorem ipsum"


Working with Controls on Forms and Reports[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900