Label style when controls property.Locked = True

N

Niklas Östergren

Hi!

Is is possible to somehow get an assosiated lable to a bound control where
the property Locked = True to be displayed with Etched style?

The lable will get Etched style if the control Locked property = False and
property Enable = False. But I´d like to have two controls on my form which
is locked and I´d like to change the style of the labels between Etched and
Flat (Normal) depending on status on a checkbox.

Or is it possible to assosiate several lables to the same control? Because I
have some controls which property Locked = False which I could use to set
style on the labes if so.

If so how do I change assosiation for a control when using Access 2003?

TIA!
// Niklas
 
D

Douglas J. Steele

Do you know the associated label or not? If you do, then when you lock the
bound control, you can change the SpecialEffect property of the label to
acEffectEtched (3). Remember to change it back to acEffectNormal (0) when
you unlock the bound control.

While there probably is a method for determine the attached label for a
given control, I can't think of it off the top of my head. Labels, however,
have a Parent property that points to the control to which they're attached,
so I suppose you could always use code like:

Dim ctlCurr As Control

For Each ctlCurr In Me.Controls
If TypeOf ctlCurr Is Label Then
If ctlCurr.Parent.Locked = True Then
ctlCurr.SpecialEffect = acEffectEtched
Else
ctlCurr.SpecialEffect = acEffectNormal
End If
End If
Next ctlCurr
 
D

Douglas J. Steele

I just remembered how to get the attached label.

Each textbox has a Controls collection associated with it. You should be
able to do something like:

Me.Text0.Locked = Not Me.Text0.Locked
Me.Text0.Controls(0).SpecialEffect = IIf(Me.Text0.Locked,
acEffectEtched, acEffectNormal)

I haven't done any testing to see whether it's possible that the associated
label might not be the first element in the Controls collection.
 
N

Niklas Östergren

"Do you know the associated label or not? If you do, then when you lock the
bound control, you can change the SpecialEffect property of the label to
acEffectEtched (3). Remember to change it back to acEffectNormal (0) when
you unlock the bound control."

Well, maby I didn´t explaned myself good enough! This code:
Me.txtExplanation.SpecialEffect = acEffectEtched '(Just used as an
example)

Does only effect the frame which the text are located in but not the text
itself.

What I´d like to do is to have the same effect on the text on the labels,
just the way they look when you set Enable = False for a control with an
assosiated label. The text gets Etched.

I havn´t looked thouroughly to the rest of your code but I will later today.
Maby I have missed something there.

Mean while Thank´s a lot for trying to help me out!

// Niklas
 
N

Niklas Östergren

"The lable will get Etched style if the control Locked property = False and
property Enable = False. But I´d like to have two controls on my form which
is locked and I´d like to change the style of the labels between Etched and
Flat (Normal) depending on status on a checkbox."

What I´m trying to say here is that if you have a textcontrol on a form and
set property.Enable = False for that control the text on the associated
label for that control will be formatted with Etched -style (the text).

But if you also set property.Locked for the same textcontrol the lable will
be displayed with Normal style.

So what I´d like to do, if possible, is to have a couple of textcontrol
locked and when a checkbox is set to 0 (zero/off/no) then shall the labels
for these controls be in Etched -style. Amonge other controls which are NOT
locked.

The reason to this is that I let the user switch an option on/off with this
checkbox and in some of the controls the user can change some variables but
on two controls they can NOT. But I still want to show the stored value for
the user.

TIA and Happy New Year!
// Niklas
 

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