Not really sure about the exact Input Mask you need, since it depends on whether or not the number of digits to be entered is fixed or variable, but after you get that straight, this code will only allow the physical entry (by keyboard) of digits, and pops up a MessageBox if the user attempts to enter alpha characters. The code also allows for entry from the KeyPad and allows the use of navigation keys.
Code:
Private Sub YourTextBoxName_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 48 To 57
'Do nothing: Numerical characters (digits) are allowed
Case vbKeyDelete, vbKeyBack, vbKeyReturn, vbKeyRight, vbKeyLeft, vbKeyTab
'Do nothing: Allow Delete and Navigation keys to be used
Case vbKeyNumpad0, vbKeyNumpad1, vbKeyNumpad2, vbKeyNumpad3, vbKeyNumpad4, vbKeyNumpad5, vbKeyNumpad6, vbKeyNumpad7, vbKeyNumpad8, vbKeyNumpad9
'Do nothing: Allow input from Numbers Keypad
Case Else
'Don't allow any other keys to be used
MsgBox "Please Enter Digits Only!"
KeyCode = 0
End Select
End Sub
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007