I've read examples I found on Google, but none work.
I would like to put a public function into the OnKeyPress event of many unbound textboxes on my form that would only allow the user to enter approved characters (alphanumeric).
Any suggestions?
I've read examples I found on Google, but none work.
I would like to put a public function into the OnKeyPress event of many unbound textboxes on my form that would only allow the user to enter approved characters (alphanumeric).
Any suggestions?
Well, generally speaking the code behind the keypress event would examine KeyAscii, and conditionally return something different. If you wanted to use a function for that, it would have to accept KeyAscii as an input parameter, and return one back. Behind each textbox's keypress event, you'd call that function and use the return, like
KeyAscii = FunctionName(KeyAscii)
Your function would examine the input, and either return it back or whatever you want substituted (probably 0).
I put "KeyAscii = KeyValid(KeyAscii)" into my event and it says it doesn't know what it is. "Microsoft Access cannot find the object".
Any ideas?
I under the idea of making a function to return a modified KeyAscii number... but calling it from the textbox control's onkeypress event isn't working thus far.
That would have to be in the VBA code editor, not right in the properties window, which is where it sounds like you have it.
http://www.baldyweb.com/FirstVBA.htm
So I'll have to have a controlname_keypress() function for every control I want to use this?
I have a LOT of controls.
Is there any way all of the controls can use one keypress function?
Thanks for your assistance.
You'd have one function, called from multiple controls. Each control would have that single line of code.