ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox change issue (https://www.excelbanter.com/excel-programming/432231-textbox-change-issue.html)

Patrick C. Simonds

TextBox change issue
 
I want to run a test on my TextBox which will set my OptionButtons to false
of someone changes the contents of the TextBox and it works fine when they
make changes. My problem is that if they click in the TextBox then click
some where else on the UserForm the OptionButtons are set to False, even
though no change was made to the TextBox.

Private Sub TextBox2203_Change()

If Me.Visible = False Then Exit Sub

Me.TextBox2203 = UCase(Me.TextBox2203.Text)

If TextBox2203.Value = rng1(1, 7) Then
GoTo Finished
End If

OptionButton2201.Value = False
OptionButton2202.Value = False
OptionButton2203.Value = False
OptionButton2204.Value = False
OptionButton2205.Value = False
OptionButton2206.Value = False

Finished:

TextBox2203.BackColor = &H80000005

End Sub


smartin

TextBox change issue
 
Patrick C. Simonds wrote:
I want to run a test on my TextBox which will set my OptionButtons to
false of someone changes the contents of the TextBox and it works fine
when they make changes. My problem is that if they click in the TextBox
then click some where else on the UserForm the OptionButtons are set to
False, even though no change was made to the TextBox.

Private Sub TextBox2203_Change()

If Me.Visible = False Then Exit Sub

Me.TextBox2203 = UCase(Me.TextBox2203.Text)

If TextBox2203.Value = rng1(1, 7) Then
GoTo Finished
End If

OptionButton2201.Value = False
OptionButton2202.Value = False
OptionButton2203.Value = False
OptionButton2204.Value = False
OptionButton2205.Value = False
OptionButton2206.Value = False

Finished:

TextBox2203.BackColor = &H80000005

End Sub


I cannot reproduce this. A form with a textbox and other controls does
not fire a change event when the textbox is clicked, nor when something
else is then clicked. Do you also have a click event on the textbox?

Norie

TextBox change issue
 
What is the purpose of this?

If TextBox2203.Value = rng1(1, 7) Then
GoTo Finished
End If

Are you sure that's doing what you want, whatever that is?

Try stepping through the code and see what's happening - and I would
recommend you don't use Goto.

Private Sub TextBox2203_Change()

If Len(TextBox2203.Value) 0 Then
OptionButton2201.Value = False
OptionButton2202.Value = False
OptionButton2203.Value = False
OptionButton2204.Value = False
OptionButton2205.Value = False
OptionButton2206.Value = False
Else
TextBox2203.BackColor = &H80000005
End If


End Sub


All times are GMT +1. The time now is 08:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com