Change and restore label caption

G

Guest

I need to change by code some labels caption and hide some controls in a subform
This according with an attribute the user chooses in a combo box on the top
I create a table to put alternative labels ( attribute - label name - alternative caption )
When user updates the main combo according to the attribute I change caption of the required labels :
....
do while not rst.eof
frm(rst!labelname).caption=rst!alternative_caption
rst.movenex
loo
....

Each attribute will change only some label, how can I restore the original caption for each label ??

I won't close an open the form
I can put the original labels into an array at form open ..

There are other solution ??
There is a label property containing the original labels, the ones of form structure ?

Thanks
Silvia
 
R

Ronald W. Roberts

silvia said:
I need to change by code some labels caption and hide some controls in a subform.
This according with an attribute the user chooses in a combo box on the top.
I create a table to put alternative labels ( attribute - label name - alternative caption ).
When user updates the main combo according to the attribute I change caption of the required labels :
....
do while not rst.eof
frm(rst!labelname).caption=rst!alternative_caption
rst.movenext
loop
....

Each attribute will change only some label, how can I restore the original caption for each label ???

I won't close an open the form.
I can put the original labels into an array at form open ...

There are other solution ???
There is a label property containing the original labels, the ones of form structure ??

Thanks
Silvia
When the form opens run thru the control collection and save the caption
in the Tag. Then when you
want to restore the caption use the Tag.

Dim ctl As Control
For Each ctl In Me.Controls
if ctl.ControlType = acLabel then
ctl.Tag = ctl.Caption
endif
Next ctl

To restore
For Each ctl In Me.Controls
if ctl.ControlType = acLabel then
ctl.Caption = ctl.Tag
endif
Next ctl


acLabel
acRectangle
acLine
acImage
acCommandButton
acOptionButton
acCheckBox
acOptionGroup
acBoundObjectFrame
acTextBox
acListBox
acComboBox
acSubform
acObjectFrame
acPageBreak
acPage
acCustomControl
acToggleButton
acTabCtl


Air Code

Ron
 

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