Texbox validation: keystroke and field

HartJF

Registered User.
Local time
Today, 05:59
Joined
Jul 23, 2010
Messages
34
I am trying to perform input validation on a textbox. I was hoping to alert the user as soon as an invalid character has been entered. I have been frustrated using the OnKeyPress and OnKeyDown events, so I am considering a new tack: full field validation.

My questions are two. First, does a good discussion of keystroke-validation exist? I understand that the OnKeyPress event does not trap control characters; since I need to handle the Delete key, OnKeyPress is not useful.

Second, when does the textbox receive its value? What event is most appropriate to check -- OnDirty, OnExit, OnLostFocus, ...? I have tried to read the value in an OnExit procedure after at least two keystroke have been submitted. Still, the control behaves as if it does not yet have a value.

Thanks in advance for your assistance.
 
To do a check for the value, use either the before update, or after update events I would think.
 
Use the KeyDown event and you can check the SHIFT variable to see if ALT or CTRL or SHIFT has been chosen.
 
Thanks for your quick response, Kryst.

This is an unbound form. Are the before- and after-update events relevant? I thought (perhaps mistakenly) that those events related to updating a field in a record.
 
Thanks, Bob. Everyone is at attention today, huh?

The validation is contextual. Can I see the previous characters in the control when the KeyDown event occurs?
 
Thanks for your quick response, Kryst.

This is an unbound form. Are the before- and after-update events relevant? I thought (perhaps mistakenly) that those events related to updating a field in a record.

Bob, please correct me if I'm wrong, but I don't think unbound or bound effects what events are viable or not. the before update and after update events would still fire, so you can still use code, I just tested before update, and it worked.
 
Bob, please correct me if I'm wrong, but I don't think unbound or bound effects what events are viable or not. the before update and after update events would still fire, so you can still use code, I just tested before update, and it worked.
That is true.

However, to capture the keystrokes, including whether the ALT, CTRL, or SHIFT key is pressed, the KeyDown event can handle that.
 
Wonderful, folks! I've a couple of tricks to try!
 

Users who are viewing this thread

Back
Top Bottom