SteveL13
asked on
All object on a tab disabled but can I change the forecolor?
I have a tab on a form disabled but what the forecolor to be black. Is there a way to do this without having to code a separate line for each object on the tab?
I've tried this but it doesn't work:
If DBEngine.Workspaces(0).Use rs(Current User).Name = "Shop" Then
Me.Casting.Enabled = False
Me.Casting.ForeColor = vbBlack
End If
I've tried this but it doesn't work:
If DBEngine.Workspaces(0).Use
Me.Casting.Enabled = False
Me.Casting.ForeColor = vbBlack
End If
but what the forecolor to be black.What forecolor do you want to change? A TabPage doesn't have a ForeColor property.
You can loop through the Controls collection of the TabPage's controls:
Dim ctl As Control
On Error Resume Next
For each ctl in Me.MyTabPage.Controls
ctl.Forecolor = vbBlack
Next
>> TabPage doesn't have a ForeColor property.
Ah... I was assuming that "Casting" was a textbox or other control.
With a Textbox, Locked = True/Enabled = false will prevent data modifications, but leave the text color unchanged (it won't take on the 'disabled' look).
Ah... I was assuming that "Casting" was a textbox or other control.
With a Textbox, Locked = True/Enabled = false will prevent data modifications, but leave the text color unchanged (it won't take on the 'disabled' look).
ASKER
Here is what I have so far but the forecolor is still grayed out and I need it to be black on each object on the tab of the form.
Dim ctl As Control
If DBEngine.Workspaces(0).Use rs(Current User).Name = "Shop" Then
Me.Casting.Enabled = False
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
Next
??
Dim ctl As Control
If DBEngine.Workspaces(0).Use
Me.Casting.Enabled = False
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
Next
??
ASKER
By the way. the code is on the onopen event of the form. I assume that is where it should be, right?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For some reason when I used:
If DBEngine.Workspaces(0).Use rs(Current User).Name = "Shop" Then
Me.Casting.Enabled = False
Me.Casting.Locked = True
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
Next
the form wouldn't open.
So I tried:
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
ctl.Locked = True
ctl.Enabled = False
Next
And it worked! Thanks.
If DBEngine.Workspaces(0).Use
Me.Casting.Enabled = False
Me.Casting.Locked = True
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
Next
the form wouldn't open.
So I tried:
On Error Resume Next
For Each ctl In Me.Casting.Controls
ctl.ForeColor = vbBlack
ctl.Locked = True
ctl.Enabled = False
Next
And it worked! Thanks.
Open in new window