global validation routine

derlwyn

Registered User.
Local time
Today, 21:03
Joined
Mar 21, 2003
Messages
12
Help wanted

I need to build a DB with numersous forms in it

Several of these form ask for alphabetic data only to be input (letters only)

I can write, using keypress methods, validation routines for these text boxes individually.

However, is there a way of writing a public function in a module and then calling this function from anywhere in my Db

I have tried the following

module code

Public Sub lettersonly(key As Integer)
Select Case key
Case 65 To 90, 97 To 122, 8, 32
key = key
Case Else
key = 0
End Select
End Sub

Form code

Private Sub txtname_KeyPress(keyascii As Integer)
lettersonly (keyascii)
End Sub

However it does not work, and the textbox still accepts non-alphabetical data

Any help would be greatly appreciated

Thanks
 

Attachments

Sure; you want lettersonly to also pass back an integer, and use it in the calling code.
 
Try using the keydown method also
 

Users who are viewing this thread

Back
Top Bottom