![]() |
Take action after entry in a textbox (or after tabbing out of/into it)
Hi all, I have a userform with some text boxes, and I want one of them to be grayed out depending on the entry in the one before it. If the user types "FL" in the first box, I want the second to be disabled. The trouble is that I want it to check this after the entry in the first box is made and while the userform is still up. How do I make it happen after the entry is made? It would also work if I could make it happen upon tabbing out of the box or into another. Here's the code I'm trying: Private Sub txtFee_Change() 'grays out the fee box if txtState = FL If txtState = "FL" Then txtFee.Enabled = False Else: txtFee.Enabled = True End If End Sub This code is fine and works for graying out, but only if the txtState = "FL" at initialization. I want it to work right when FL is entered. Thanks for your help! -- Lost! ------------------------------------------------------------------------ Lost!'s Profile: http://www.excelforum.com/member.php...o&userid=23990 View this thread: http://www.excelforum.com/showthread...hreadid=385312 |
Take action after entry in a textbox (or after tabbing out of/into it)
Hi, To acomplish what you need intead of Code: -------------------- Private Sub txtFee_Change() 'grays out the fee box if txtState = FL If txtState = "FL" Then txtFee.Enabled = False Else: txtFee.Enabled = True End If End Sub -------------------- Try Private Sub txtFee_AfterUpdate() 'grays out the fee box if txtState = FL If txtState = "FL" Then txtFee.Enabled = False Else: txtFee.Enabled = True End If End Sub In design mode double click the txtFee Text Box and insert the modified code. If it works invite us to Florida:) Success Jose Luis Lost! Wrote: Hi all, I have a userform with some text boxes, and I want one of them to be grayed out depending on the entry in the one before it. If the user types "FL" in the first box, I want the second to be disabled. The trouble is that I want it to check this after the entry in the first box is made and while the userform is still up. How do I make it happen after the entry is made? It would also work if I could make it happen upon tabbing out of the box or into another. Here's the code I'm trying: Private Sub txtFee_Change() 'grays out the fee box if txtState = FL If txtState = "FL" Then txtFee.Enabled = False Else: txtFee.Enabled = True End If End Sub This code is fine and works for graying out, but only if the txtState = "FL" at initialization. I want it to work right when FL is entered. Thanks for your help! -- jose luis ------------------------------------------------------------------------ jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312 View this thread: http://www.excelforum.com/showthread...hreadid=385312 |
Take action after entry in a textbox (or after tabbing out of/into it)
That worked perfectly. Thanks! -- Lost ----------------------------------------------------------------------- Lost!'s Profile: http://www.excelforum.com/member.php...fo&userid=2399 View this thread: http://www.excelforum.com/showthread.php?threadid=38531 |
Take action after entry in a textbox (or after tabbing out of/into it)
Nice to hear that!!! Now just missing the Florida Vacation :rolleyes: Carpe Diem! Jose Luis Lost! Wrote: That worked perfectly. Thanks!! -- jose luis ------------------------------------------------------------------------ jose luis's Profile: http://www.excelforum.com/member.php...o&userid=13312 View this thread: http://www.excelforum.com/showthread...hreadid=385312 |
All times are GMT +1. The time now is 04:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com