Textboxes on my UserForm are not dimmed when disabled

sbendbuckeye

Active Member
Joined
Nov 26, 2003
Messages
440
I have an Excel UserForm with 2 textboxes on it, txtBegDate and txtEndDate. For monthly or semimonthly payrolls they contain the day or days when payroll is processed (eg 1 and 15, 15 and EOM or just 15 for monthly, etc.). If the payroll is weekly then the textboxes need to be dimmed.

In the after update event for the ListBox which allows the user to select the payroll code I have logic similar to this:

txtBegDate.Enabled = IsMonthlyPayroll or IsSemiMonthlyPayroll

The Is functions are boolean and return True or False. Even thougth they are not greyed out they appear to be locked as you cannot give them focus or enter data into them. I'm using ExcelXP if that makes a difference.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi sbendbuckeye,
Give this a shot. I think it'll work for what you want.
Might be a better / quicker way but it works for me.
(I'm using xl 2000 though, so...)
Code:
Private Sub DimmedTextBoxTest()
If Not MonthlyPayroll Then
    If Not SemiMonthlyPayroll Then
txtBegDate.Enabled = False
txtBegDate.BackColor = &H8000000F
Else:
txtBegDate.Enabled = True
End If
End If
End Sub

You can choose the background color you want by looking at what's offered in the textbox background color properties.

This work in xp?
Dan
 
Upvote 0
Thanks,

It worked like a charm. I added the following line to set the background color back to white if it was reenabled:

txtBegDate.BackColor = &HFFFFFF
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,262
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top