PDA

View Full Version : SOLVED: Uncooperative label control properties



eed
06-29-2004, 10:37 AM
Hi,

I am working on a piece of code which, based on the user's selection, loops through all the db forms and changes several properties of all label controls. Among other things, I want the code to change the labels' bg color based on user selection, but I never want the labels' bg style to be transparent.

I started with all labels set to normal, and the default control style is normal. My code specifically sets it to normal as well. After the code runs, the default control style is set to normal, but EVERY LABEL has reverted to transparent. I cannot figure out why they are doing this!! I am confused and frustrated.

Please help if you can. I have posted the most relevant chunk of my code below, dunno if it will help or not, please ask if more info would help you help me!! Suggestions are deeply appreciated. Thank you so much!!!


For Each doc In ctr.Documents
DoCmd.OpenForm doc.Name, acDesign, , , , acHidden
Set frm = Forms(0)
If frm.Tag = "BGNrml_TextNrml" Then
With frm
.Section(acDetail).BackColor = 16764057
.Section(acPageHeader).BackColor = 16764057
.Section(acPageFooter).BackColor = 16764057
.Section(acHeader).BackColor = 16764057
.Section(acFooter).BackColor = 16764057
End With
End If
For Each ctl In frm.Controls
If ctl.Tag = "BGNrml_TextNrml" Then
ctl.BackStyle = Normal
ctl.BackColor = 16764057
ctl.ForeColor = 0
ElseIf ctl.Tag = "BGNrml_TextHighlight" Then
ctl.BackStyle = Normal
ctl.BackColor = 16764057
ctl.ForeColor = 16711680
ElseIf ctl.Tag = "BGHighlight_TextDrk" Then
ctl.BackStyle = Normal
ctl.BackColor = 16776960
ctl.ForeColor = 0
ElseIf ctl.Tag = "LineNrml" Then
ctl.BorderColor = 0
ElseIf ctl.Tag = "LineHighlight" Then
ctl.BorderColor = 16711680
End If
Next ctl
DoCmd.close acForm, doc.Name, acSaveYes
Next doc

TonyJollans
06-29-2004, 03:31 PM
Hi eed,

The BackStyle Property takes a numeric value (0=Transparent and 1=Normal). You are setting it to a variable, Normal. Assuming you don't have it declared, and are not using "Opton Explicit", Normal will default to a value of 0 (i.e. transparent).

To make it work, use

ctl.BackStyle = 1

To make it slightly easier to understand, define and use some contants. At the top of your module add ..


Enum myBackStyles
myTransparent
myNormal
End Enum


.. and then use

ctl.BackStyle = myNormal

eed
06-30-2004, 05:10 AM
Thanks Tony, I appreciate the reply, but the procedure still doesn't run correctly.


I had my bg style set to numerics first, then decided to try text settings (normal/transparent) based on something I saw in a help file, but neither works. Even when I set it to 1, all the labels decide to become transparent instead.
Any more ideas as to what might be going wrong here? I've been testing, tweaking, and retesting for a week, and I know I must be overlooking something but I can't fathom what. Thanks to all who read, and thanks in advance for any further replies!!

eed
06-30-2004, 05:20 AM
Okay, well, it didn't like the numeric setting, but it actually DID like your Enum "myNormal" idea. Now the labels are working. I've still got to sort out some other issues, but at least I don't have to agonize over this one anymore. Thanks, Tony!!!