Referencing objects in option group

  • Thread starter Thread starter Jim Shaw
  • Start date Start date
J

Jim Shaw

BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?

Thanks
Jim
 
You don't indicate what the name of the label is... so...
If, for example, the Label Name is MyCheckBoxLabel, then to change it...
MyCheckBoxLabel.Caption = "MyText"
hth
Al Camp
 
Al, you missed it.
"cbxLabel" is the name of the label.
Your code is the same as my first attempt (cbx:Label = myText)

The code does not work because the check box is in an option group.
Addressability must somehow be made through the option box (named
"optFrame").

Any other thoughts?
Jim

AlCamp said:
You don't indicate what the name of the label is... so...
If, for example, the Label Name is MyCheckBoxLabel, then to change it...
MyCheckBoxLabel.Caption = "MyText"
hth
Al Camp

Jim Shaw said:
BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?

Thanks
Jim
 
Jim said:
BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?


1. The colon is just plain invalid.
2. This should work.
3. - 5. Going through the Frame is not really required here,
but if you wanted to, you could use:
optFrame.Controls!cbxLabel.caption = myText

I think your problem is that you want to do this for a whole
bunch of these labels and you don't want to have a line of
code for each label. If that's what you're leading up to,
then name all the labels something like lblChk1, lblChk2,
. . . and play around with using somthing like this air
code:

Set rs = db.OpenRecordset("thetable")
Do Until rs.EOF
Me("lblChk" & rs!numberfield).Caption = rs!description
rs.MoveNext
Loop
rs.Close : Set rs = Nothing

In your other thread, you mentioned a concern about future
need for additional check boxes. This is getting pretty
advanced, but it could be handled by adding a bunch of
invisible check boxes and making the visible as needed in
the above code.
 
Jim,
I only indicated the how to address the checkbox label caption, since you
don't need to use the option frame name.
No...
cbx:Label = myText
is not the same as
cbxLabel.Caption = "MyText"
the colon you used is incorrect.
I stand by my response...
The Frame (option group) name does not have to be included in the code.
Al Camp

Jim Shaw said:
Al, you missed it.
"cbxLabel" is the name of the label.
Your code is the same as my first attempt (cbx:Label = myText)

The code does not work because the check box is in an option group.
Addressability must somehow be made through the option box (named
"optFrame").

Any other thoughts?
Jim

AlCamp said:
You don't indicate what the name of the label is... so...
If, for example, the Label Name is MyCheckBoxLabel, then to change it...
MyCheckBoxLabel.Caption = "MyText"
hth
Al Camp

Jim Shaw said:
BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?

Thanks
Jim
 
Marsh;
Thank you. You have saved my day! I used the do loop approach and it
worked just fine. I also like your approach to additional check boxes.

I wish there was a location somewhere that explained the use of all that
punctuation and dereferencing VBA uses. I haven't found it in the VBA help
files. And people complain about the syntax in C++...

I'm going to add a front end form to the report's open event logic to
provide the data for the report. I know how to call up the form and
transfer control to it. I'm hoping I can reference the report's data
controls from the front end form to pass the input data back to the report
without going through an intermediate table. That part I have not figured
out yet.

Jim

Marshall Barton said:
Jim said:
BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?


1. The colon is just plain invalid.
2. This should work.
3. - 5. Going through the Frame is not really required here,
but if you wanted to, you could use:
optFrame.Controls!cbxLabel.caption = myText

I think your problem is that you want to do this for a whole
bunch of these labels and you don't want to have a line of
code for each label. If that's what you're leading up to,
then name all the labels something like lblChk1, lblChk2,
. . . and play around with using somthing like this air
code:

Set rs = db.OpenRecordset("thetable")
Do Until rs.EOF
Me("lblChk" & rs!numberfield).Caption = rs!description
rs.MoveNext
Loop
rs.Close : Set rs = Nothing

In your other thread, you mentioned a concern about future
need for additional check boxes. This is getting pretty
advanced, but it could be handled by adding a bunch of
invisible check boxes and making the visible as needed in
the above code.
 
Jim said:
Thank you. You have saved my day! I used the do loop approach and it
worked just fine. I also like your approach to additional check boxes.

I wish there was a location somewhere that explained the use of all that
punctuation and dereferencing VBA uses. I haven't found it in the VBA help
files. And people complain about the syntax in C++...

You could probably find most all of this kind of thing
scattered across several of the better books, but, really,
this stuff is just logical consequences of the basics
explained in Help - if you can find it :-(

Experience is the best teacher ;-)

I'm going to add a front end form to the report's open event logic to
provide the data for the report. I know how to call up the form and
transfer control to it. I'm hoping I can reference the report's data
controls from the front end form to pass the input data back to the report
without going through an intermediate table. That part I have not figured
out yet.

I prefer to have a form that opens the report, instead of
the report opening a form, but I don't see a good reason for
you not to.

I'm sure we'll hear from you when you run into the next
layer of complexity ;-))
--
Marsh
MVP [MS Access]

BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption of the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?

"Marshall Barton" wrote
1. The colon is just plain invalid.
2. This should work.
3. - 5. Going through the Frame is not really required here,
but if you wanted to, you could use:
optFrame.Controls!cbxLabel.caption = myText

I think your problem is that you want to do this for a whole
bunch of these labels and you don't want to have a line of
code for each label. If that's what you're leading up to,
then name all the labels something like lblChk1, lblChk2,
. . . and play around with using somthing like this air
code:

Set rs = db.OpenRecordset("thetable")
Do Until rs.EOF
Me("lblChk" & rs!numberfield).Caption = rs!description
rs.MoveNext
Loop
rs.Close : Set rs = Nothing

In your other thread, you mentioned a concern about future
need for additional check boxes. This is getting pretty
advanced, but it could be handled by adding a bunch of
invisible check boxes and making the visible as needed in
the above code.
 
Al
My apologies...the colon was a mistype that did not appear in my code, only
in my message here.
I'm now successfully accessing the label.caption.
Thanks
Jim

AlCamp said:
Jim,
I only indicated the how to address the checkbox label caption, since you
don't need to use the option frame name.
No...
cbx:Label = myText
is not the same as
cbxLabel.Caption = "MyText"
the colon you used is incorrect.
I stand by my response...
The Frame (option group) name does not have to be included in the code.
Al Camp

Jim Shaw said:
Al, you missed it.
"cbxLabel" is the name of the label.
Your code is the same as my first attempt (cbx:Label = myText)

The code does not work because the check box is in an option group.
Addressability must somehow be made through the option box (named
"optFrame").

Any other thoughts?
Jim

AlCamp said:
You don't indicate what the name of the label is... so...
If, for example, the Label Name is MyCheckBoxLabel, then to change it...
MyCheckBoxLabel.Caption = "MyText"
hth
Al Camp

BlankI have a series of check boxes and associated labels within an option
group on my report.
Using data from an underlying table, I'd like to modify the caption
of
the
check box's label.

I've tried:
cbx:Label = myText
cbxLabel.caption = myText
optFrame.cbxLabel.caption = myText
optFrame!cbxLabel.caption = myText
[optFrame]!cbxLabel.caption = myText
Neither works. I keep getting "object not found" messages.
What is the proper way to do this in VBA 2002?

Thanks
Jim
 
Back
Top