Hi Guys
sorry if this has been asked before
i have loads of forms that have text boxes that are for collecting numbers, I.E phone numbers etc
these are set as text in the database feilds
i have added this code on the keypress event of some of the form fields and it works really well, this prevent entering text, only numbers
Code:
Select Case KeyAscii
Case 8, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 127
Case Else
KeyAscii = 0
End Select
what i would like to do to stop me entering the same code loads of time, is call this from a module
something like
Code:
' ----------------------------------------------------------------
' Procedure Name: NumbersOnly
' Purpose: Stop Entering letters
' Procedure Kind: Function
' Procedure Access: Public
' Parameter KeyAscii (Integer): This Is The ASCII Numbers For The Numberic, Number, Delete, Backspace And Arrow keys Key
' Date: 05/06/2018
' ----------------------------------------------------------------
Function NumbersOnly(KeyAscii As Integer)
On Error GoTo NumbersOnly_Error
Select Case KeyAscii
Case 8, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 127
Case Else
KeyAscii = 0
End Select
On Error GoTo 0
Exit Function
NumbersOnly_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure NumbersOnly, line " & Erl & "."
End Function
what i cant seem to figure out is the code i would put in the keypress event on the forms text boxes
if i put
i get "Compile Error Argument not optional"
any help would be fantastic
Steve