I'm working on a project that has a form with several text boxes. These text boxes include "text and Numeric Data".
Using KeyAscii, I would like for the data to be restricted to the proper text boxes. In other words; if a text box is setup to accept text only, and if a numeric value is entered in that text box, not only do I want the text box not to accept the numeric data, I would also like a "msgbox indicating an error message as soon as the wrong data had been entered.
The following code does work in terms of not allowing the wrong data to be entered. However, as I just mentioned, I also need a "msgbox" to appear as soon as the wrong data is entered. So, can you provide some sample code that would include a message box?
Private Sub txtForeName_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0" And KeyAscii <= Asc("9" Then KeyAscii = 0
End Sub
Using KeyAscii, I would like for the data to be restricted to the proper text boxes. In other words; if a text box is setup to accept text only, and if a numeric value is entered in that text box, not only do I want the text box not to accept the numeric data, I would also like a "msgbox indicating an error message as soon as the wrong data had been entered.
The following code does work in terms of not allowing the wrong data to be entered. However, as I just mentioned, I also need a "msgbox" to appear as soon as the wrong data is entered. So, can you provide some sample code that would include a message box?
Private Sub txtForeName_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0" And KeyAscii <= Asc("9" Then KeyAscii = 0
End Sub