Label name referring to subform (1 Viewer)

NNothard

Registered User.
Local time
Today, 06:08
Joined
Jun 7, 2006
Messages
18
Just a quick question, I can't seem to get this right (as usual :confused: )

I have a form and I want the label in the header to display the text from a field in a related subform. I have tried the following syntax to no avail:
=[Forms]![sfrmCompanyName]![LastName]

Any suggestions

Thanks in advance

Nicolas
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:08
Joined
Feb 19, 2002
Messages
43,445
It doesn't usually make any sense to reference the rows of a subform from the mainform since all you can reference directly is the current record of the subform. But, the syntax when used as a ControlSource is:

=[Forms]![mainformname]![sfrmCompanyName].Form![LastName]

From VBA, you could use the shorter syntax:
Me.sfrmCompanyName.Form!LastName
 

NNothard

Registered User.
Local time
Today, 06:08
Joined
Jun 7, 2006
Messages
18
Thank-you very much, that worked first time.
 

Users who are viewing this thread

Top Bottom