jacobrcotton
Board Regular
- Joined
- Jan 28, 2017
- Messages
- 51
Hi,
This code was working this morning! I don't know where I've broken it.
this is a different problem, but using the similar coding and the same project as a previous thread (https://www.mrexcel.com/forum/excel...rform-textbox_change-call-validation-sub.html)
My current code below is taking the input from a TextBox and running it through a series of validation tests. The first test is titled IsNumericTest and (surprise surprise) it is testing that the Textbox input is nonNull & is a number However, I can't seem to get the MsgBox to trigger (unless i comment out the With & If coding, basically forcing the MsgBox to appear without criteria). I've narrowed this down to something wrong with my .ActiveControl and the .Value coding, but I dont know what is actually wrong.
I can get the code to work by directly referencing the input textbox as "IndDedINN.Value", but this defeats the purpose as I need to run multiple TextBoxes through the same IsNumericTest validation.
*Note that I have several of the validation tests (ie, NotLessThanZeroTest, LessThanMaximumTest, etc) that are all exhibiting the same problem.
Thoughts?
This code was working this morning! I don't know where I've broken it.
this is a different problem, but using the similar coding and the same project as a previous thread (https://www.mrexcel.com/forum/excel...rform-textbox_change-call-validation-sub.html)
My current code below is taking the input from a TextBox and running it through a series of validation tests. The first test is titled IsNumericTest and (surprise surprise) it is testing that the Textbox input is nonNull & is a number However, I can't seem to get the MsgBox to trigger (unless i comment out the With & If coding, basically forcing the MsgBox to appear without criteria). I've narrowed this down to something wrong with my .ActiveControl and the .Value coding, but I dont know what is actually wrong.
I can get the code to work by directly referencing the input textbox as "IndDedINN.Value", but this defeats the purpose as I need to run multiple TextBoxes through the same IsNumericTest validation.
*Note that I have several of the validation tests (ie, NotLessThanZeroTest, LessThanMaximumTest, etc) that are all exhibiting the same problem.
Code:
Private Sub IndDedINN_AfterUpdate()
IsNumericTest
End Sub
Private Sub IsNumericTest()
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Numeric Values Only" & vbNewLine & vbNewLine & "TEST: IsNumericTest"
.Value = vbNullString
End If
End With
End If
End Sub
Thoughts?