VBAmalta89
Board Regular
- Joined
- Mar 25, 2011
- Messages
- 116
I am doing some data validation on my user forms in VBA. I want the text boxes i have available to accept only numbers.
I have managed to do this for normal text boxes, however, I cannot do it for text boxes that lie within a frame. The line of code I am using is as follows for the normal text boxes:
Private Sub DisposeWood_Change()
OnlyNumbers
End Sub
Private Sub OnlyNumbers()
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
End If
End With
End If
End Sub
How do i alter this to only accept numbers in text boxes which are inside frames?
I have managed to do this for normal text boxes, however, I cannot do it for text boxes that lie within a frame. The line of code I am using is as follows for the normal text boxes:
Private Sub DisposeWood_Change()
OnlyNumbers
End Sub
Private Sub OnlyNumbers()
If TypeName(Me.ActiveControl) = "TextBox" Then
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
End If
End With
End If
End Sub
How do i alter this to only accept numbers in text boxes which are inside frames?