Is there a way to in a field rather than causing an error message because in
a currency field someone typed in a alpha characterto just let the field
ignore the alpha characters and only put in numeric numbers that are typed in.
Thanks in advance
An Input Mask (as Klatuu suggests) is certainly the simplest solution
to implement, and will accomplish the goal - the user will get an
error message box, though, which might interrupt their thought
process. (It will fairly quickly train them not to type letters in the
field though!)
Alternatively, you can use VBA code in the control's KeyDown event to
trap each keystroke, check to see if it's numeric, and discard it if
not. You need to set the Form's KeyPreview property to True, and use
code like
Private Sub txtMyTextbox_KeyDown(KeyCode As Integer, Shift as Integer)
If KeyCode < Asc("0") Or KeyCode > Asc("9") Then ' trap all nonnumeric
KeyCode = 0 ' Untype the character - user gets nothing
Beep ' let the user know something odd happened
End If
End Sub
John W. Vinson[MVP]