Full Version: using caption property on a "Control" object
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
pwatson
I'm working with some sample code, that is written as:

dim ctl as Control
ctl.Caption = "okely dokely."

When I try to code this, ctl does not have a caption property.

I'm wondering if the code was written for a different version of Access than the one I'm using, or if it won't let you set a caption unless you're specifically dealing with a label?

Any insights?

Thanks,
Paul
NoahP
A label IS a control, at least it is part of the Forms Collection.

Noah
freakazeud
Hi,
try:

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.ControlType = acLabel Then
ctl.Caption = "youcaption"
End If
Next ctl

HTH
Good luck
GlenKruger
Try:

dim ctl as Control
ctl =Me.SomeControl 'Where Some Control is the control you want to change the caption of
ctl.Caption = "okely dokely."

Or simply use the:

Me.SomeControl.Caption = "okely dokely."

In the event that you want to change the controls caption.

PS..... There are only controls on a form Fields are in Tables.

Edited by: GlenKruger on Tue Jul 12 19:11:14 EDT 2005.
pwatson
Thanks, guys.

Using "dim ctl as Control" , when I'm tying this code, as soon as I type "ctl.", a list of control properties and methods pop up. "Caption" is not included in the list. I figured since it wasn't there, I was doing something wrong. I guess there are circumstances when not all of the methods/properties available are displayed?


Paul
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.