Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select a label control indirectly 1

Status
Not open for further replies.

aldi07

MIS
Jun 22, 2010
100
CA
Hi, the question applies to Ms-Access 2003 and Ms-Access 2007:

To change a label caption in a form, the code would be:
Me.labelname.caption = “MyNewCaption”

But what if the labelname exists in a variable? (say a table field for example):
I cannot go: Me.Mytable![Field].caption = “MyNewCaption”

What would be the right code in that case?

Thank you
 


Code:
Me.labelname.caption = Me.Mytable![Field]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sorry, but you cannot use Bang(!) notation. You need to use dot notation.
Bang:Me!ControlName
Dot:Me.("ControlName")
or Me.(someVariable)
ex.
dim x as string
x = "someLabelName"
me.controls(x).caption = "MyNewCaption
 
Thanks vbaJock, I wrote that to quick.

Dot: Me.controls("controlName")
or Me.controls(someVariable)

or since the controls collection is the default property of a form, it is not required. You can.
Me("controlName)
me(someVariable)

But not Me.("controlName")

 
Thank you vbajock and MajP:
me(somevariable) did the job perfectly well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top