text box data type

sjdth

New member
Local time
Today, 01:35
Joined
Apr 17, 2002
Messages
5
Hi, pls help me with this problem

I want the user to fill in to a text box (no record source) with only "number" data type and if the user fill in with "text" data type there will be a msgbox pop up.

How can I add a code to have a msgbox pop up.

Thanks!!!
 
One way is to catch the character (number or letter) as it is typed in. You can use the On Key Press event of the text box, like this:

Private Sub Text1_KeyPress(KeyAscii As Integer)
If (KeyAscii < 48) Or (KeyAscii > 57) Then
MsgBox "Please enter numbers only"
End If
*This could get really annoying if your users are clumsy.

The values between 48 and 57 inclusive convert to the numbers 0..9. Take a look under ASCII in help.

Hope that's what you're looking for.

Glen Naysmith:D
 
Thanks alot!!!

I've found the answer for that, thanks again
 

Users who are viewing this thread

Back
Top Bottom