Hi, in my project I have a ew fields such as Telephone number and I want to add validation to them to allow only numerical data input.
I'm currently using the following code but it doesn't work:
Also, please tell me where in my code to put this.
Thanks so much!
I'm currently using the following code but it doesn't work:
Private Sub Tel_KeyPres(KeyAscii As Integer)
'Only numeric data input
If KeyAscii = vbKeyTab Or KeyAscii = vbKeyBack Then Exit Sub
'Check for alpha characters
If Not IsNumeric(Chr(KeyAscii)) Then
MsgBox "Only numerical characters allowed"
KeyAscii = 0
End If
End Sub
Also, please tell me where in my code to put this.
Thanks so much!