checkbox label

T

Terry

Hello
Is there anyway to pick up the value of a checkbox label?
EX:
When I created the checkboxes, they came with a label (which I added a
caption to).
Now I would like to pickup that caption for that checkbox's label.

ActiveControl.label.caption ---- in essence. As you know, this does not
work.

Thank you so much
Terry V
 
A

Allen Browne

The attached label is the first member of the control's Controls collection,
so its Caption would be:
[MyCheckbox].Controls(0).Caption
 
F

fredg

Hello
Is there anyway to pick up the value of a checkbox label?
EX:
When I created the checkboxes, they came with a label (which I added a
caption to).
Now I would like to pickup that caption for that checkbox's label.

ActiveControl.label.caption ---- in essence. As you know, this does not
work.

Thank you so much
Terry V
I don't know what you mean by 'pick up the value of a checkbox label'?

You can change a label's caption:
LabelName.Caption = "This is new."

You can read a label's caption:
Dim strX as String
strX = [LabelName].Caption

Are either of these what you want?
 
T

Terry

If Im understanding correctly;
If I want the caption of the activecontrol (when a checkbox is clicked) then
I could use:

var = Form.ActiveControl.Controls(0).Caption

Is this correct?

Thank you :)
Terry V

Allen Browne said:
The attached label is the first member of the control's Controls collection,
so its Caption would be:
[MyCheckbox].Controls(0).Caption

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Terry said:
Is there anyway to pick up the value of a checkbox label?
EX:
When I created the checkboxes, they came with a label (which I added a
caption to).
Now I would like to pickup that caption for that checkbox's label.

ActiveControl.label.caption ---- in essence. As you know, this does not
work.
 
T

Terry

By pickup, I mean get the caption of the activecontrol into a variable....
sorry for the confusion.

Thank you
Terry V
fredg said:
Hello
Is there anyway to pick up the value of a checkbox label?
EX:
When I created the checkboxes, they came with a label (which I added a
caption to).
Now I would like to pickup that caption for that checkbox's label.

ActiveControl.label.caption ---- in essence. As you know, this does not
work.

Thank you so much
Terry V
I don't know what you mean by 'pick up the value of a checkbox label'?

You can change a label's caption:
LabelName.Caption = "This is new."

You can read a label's caption:
Dim strX as String
strX = [LabelName].Caption

Are either of these what you want?
 
A

Allen Browne

If the active control has an attached label, it would be:
Screen.ActiveControl.Controls(0).Caption

However, I've always found that syntax to be rather error-prone, so make
sure you have error handling in your code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top